packages feed

mmsyn6ukr 0.1.0.0 → 0.2.0.0

raw patch · 4 files changed

+40/−16 lines, 4 filesdep +mmsyn3

Dependencies added: mmsyn3

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Revision history for mmsyn6ukr -## 0.1.0.0 -- 2019-11-23+## 0.1.0.0 -- 2019-11-25  * First version. Released on an unsuspecting world.++## 0.2.0.0 -- 2019-11-25++* Second version. Added the possibility for program to use the installed +SoX binary in the system to automatically create a raw PCM file into +the .wav sound file that can be easily listened to.
Main.hs view
@@ -10,13 +10,15 @@ --  -module Main where+module Main (+  main+) where ---import Data.Maybe (isJust,fromJust)+import Data.Maybe (isJust,fromJust) import System.IO  import System.Environment---import System.Process---import EndOfExe+import System.Process+import EndOfExe import Paths_mmsyn6ukr import Melodics.Ukrainian @@ -24,16 +26,24 @@ -- Inspired by: https://mail.haskell.org/pipermail/beginners/2011-October/008649.html -} +-- | The function creates a raw PCM sound file with bitrate 22050 Hz 1 mono channel 16-bit signed-integer encoding +-- and tries to automatically convert it to the .wav file with the same parameters using the system binary SoX.+-- If it is not installed properly, the program makes ending informational message for the user. main :: IO () main = do          args <- getArgs          putStrLn "Please, specify the name of the resulting sound file! Please, do NOT use '}' character and space characters!"          nameOfSoundFile <- getLine          xs <- getContents-         let ys = take (nSymbols (let zs = take 1 args in if null zs then [] else head zs)) xs in do+         let ys = take (nSymbols (let zs = take 1 args in if null zs then [] else head zs)) xs in               withBinaryFile (nameOfSoundFile ++ ".raw") AppendMode (appendS16LEFile (convertToProperUkrainian ys))-             putStr "You have a resulting file, which name begins with \"new.\" in a raw PCM format with bitrate 22050 Hz and 1 channel (mono) in the .dat format. "-             putStr "You can further process it by yourself manually, otherwise, please, install FFMpeg or LibAV executables in the directory mentioned in the variable PATH"-             putStrLn " and then run: "-             putStrLn "\"name_of_FFMpeg_or_LibAV_executable\" -f s16le -acodec pcm_s16le -ac 1 -ar 22050 -i \"name_Of_the_sound_file\" \"the_same_name_without_.dat_ending_and_with_.wav_ending\""-+         let ts = showE "sox" in if isJust ts+                      then callCommand $ fromJust ts ++ " -r22050 -c1 -L -e signed-integer -b16 new." ++ nameOfSoundFile ++ ".raw new." ++ nameOfSoundFile ++ ".wav"+                      else do +                         putStr "You have a resulting file, which name begins with \"new.\" in a raw PCM format with bitrate 22050 Hz and 1 channel (mono) in the .raw format. "+                         putStr "You can further process it by yourself manually, otherwise, please, install FFMpeg or LibAV executables in the directory mentioned in the variable PATH"+                         putStrLn " and then run: "+                         putStrLn "\"name_of_FFMpeg_or_LibAV_executable\" -f s16le -acodec pcm_s16le -ac 1 -ar 22050 -i \"name_Of_the_sound_file\" \"the_same_name_without_.dat_ending_and_with_.wav_ending\""+                         putStrLn ""+                         putStrLn "OR you can install SoX executable in the directory mentioned in the variable PATH and then run: "+                         putStrLn "\"Path_to_the_SoX_executable\" -b16 -r22050 -c1 -e signed-integer -L \"name_of_the_file_in_raw_format_with_new._prefix\" \"name_of_the_file_in_raw_format_with_new._prefix\" in the terminal."
Melodics/Ukrainian.hs view
@@ -10,7 +10,11 @@ --  -module Melodics.Ukrainian where+module Melodics.Ukrainian (+  appendS16LEFile,+  convertToProperUkrainian, +  nSymbols+) where  import Data.Char import Data.List (groupBy)@@ -33,6 +37,8 @@   data1 <- B.readFile file   let dataN = B.drop 44 data1 in return dataN ++-- | The function that actually produces a .raw file. appendS16LEFile ::  V.Vector String -> Handle -> IO () appendS16LEFile xs hdl | not (V.null xs) =    do@@ -44,15 +50,18 @@     dataList <- V.mapM takeData . V.fromList $! dataFileList     V.mapM_ (\u ->        if V.all (\z -> B.length z > 0) dataList -        then let rs =  "new." ++ (tail . dropWhile (/= ' ') . takeWhile (/= '}') . show $ hdl) in +        then let rs =  "new." ++ (tail . dropWhile (/= ' ') . takeWhile (/= '}') . show $ hdl) in do           B.appendFile rs $ dataList V.! (getBFst' (0, V.fromList [("0", 0), ("1", 1), ("а", 2), ("б", 3),              ("в", 4), ("г", 5), ("д", 6), ("дж", 7), ("дз", 8), ("е", 9), ("ж", 10), ("з", 11), ("и", 12),                ("й", 13), ("к", 14), ("л", 15), ("м", 16), ("н", 17), ("о", 18), ("п", 19), ("р", 20),                  ("с", 21), ("сь", 22), ("т", 23), ("у", 24), ("ф", 25), ("х", 26), ("ц", 27), ("ць", 28), ("ч", 29),                    ("ш", 30), ("ь", 31), ("і", 32), ("ґ", 33)]) u)         else error "Data sound file is not read!") xs+    hClose hdl                        | otherwise = return () +-- | The function that converts a written Ukrainian text into the sounding in the program phonetical respesentation. +-- It is not exact phonetically but you can make for yourself a general imression of the Ukrainian sounding. convertToProperUkrainian :: String -> V.Vector String convertToProperUkrainian ys = toVector . correctA . createTuplesByAnalysis . filterUkr $ ys 
mmsyn6ukr.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mmsyn6ukr-version:             0.1.0.0+version:             0.2.0.0 synopsis:            Can be used as a musical instrument synthesizer or for Ukrainian language listening description:         A program that can be used as a musical instrument synthesizer or for Ukrainian speech synthesis especially for poets and writers @@ -23,7 +23,6 @@   main-is:             Main.hs   other-modules:       Paths_mmsyn6ukr, Melodics.Ukrainian   -- other-extensions:-  build-depends:       base >=4.7 && <4.13, vector >=0.11 && <0.13, bytestring >=0.10 && <0.11, process >=1.4 && <1.7, mmsyn2 >=0.1.6.1 && <0.2, mmsyn5 >= 0.4 && < 1-  --                   mmsyn3 >=0.1.3.0 && <0.2+  build-depends:       base >=4.7 && <4.13, vector >=0.11 && <0.13, bytestring >=0.10 && <0.11, process >=1.4 && <1.7, mmsyn2 >=0.1.6.1 && <0.2, mmsyn3 >=0.1.3.0 && <0.2, mmsyn5 >= 0.4 && < 1   -- hs-source-dirs:   default-language:    Haskell2010