mmsyn7ukr 0.2.1.0 → 0.3.0.0
raw patch · 7 files changed
+27/−139 lines, 7 filesdep +bytestringPVP ok
version bump matches the API change (PVP)
Dependencies added: bytestring
API changes (from Hackage documentation)
- Processing_mmsyn7ukr: cleanCreatedSoundFs :: IO ()
- Processing_mmsyn7ukr: createAndPlayFs :: IO ()
- Processing_mmsyn7ukr: main6Ukr :: IO ()
- SoXBasics: cleanTemp :: IO ()
- UkrainianLControl: genControl :: String -> (String, (String, String))
- UkrainianLControl: nSymbols :: String -> Int
+ Processing_mmsyn7ukr: cleanTemp :: IO ()
Files
- ChangeLog.md +5/−0
- Main.hs +0/−6
- Processing_mmsyn7ukr.hs +7/−49
- README +8/−6
- SoXBasics.hs +0/−6
- UkrainianLControl.hs +0/−66
- mmsyn7ukr.cabal +7/−6
ChangeLog.md view
@@ -24,3 +24,8 @@ * Second version revised A. Extended the bounds for the base package dependency so that it now can be compiled for GHC 8.8.1. Added some functionality to improve the control over the program mmsyn7ukr behaviour.++## 0.3.0.0 -- 2019-12-24++* Third version. Changed behaviour of the program so that it now only creates a "voice". It allows to use additional executable mmsyn7h afterwards from the package with the same name. +The latter is very close to mmsyn6ukr but uses the data files in the directory where it is running instead of defined by the standard for Paths_mmsyn6ukr.
Main.hs view
@@ -16,7 +16,6 @@ import Control.Exception (onException) import EndOfExe (showE) import Data.Maybe (fromJust)-import SoXBasics import Paths_mmsyn6ukr import Processing_mmsyn7ukr @@ -108,8 +107,3 @@ putStrLn "" putStrLn "Your voice sound files are now created in the current directory! Use in a secure way! Remember thu initial CAUTION! " putStrLn ""- createAndPlayFs- cleanTemp- cleanCreatedSoundFs- return ()-
Processing_mmsyn7ukr.hs view
@@ -20,10 +20,11 @@ import Data.Char import Data.List (isSuffixOf) import qualified Data.Vector as V+import qualified Data.ByteString.Lazy as B import System.Process import System.IO import SoXBasics-import Melodics.Ukrainian (appendS16LEFile, convertToProperUkrainian)+import Melodics.Ukrainian (convertToProperUkrainian, takeData) import UkrainianLControl import CaseBi (getBFst') @@ -141,51 +142,8 @@ putStrLn "Please, specify the value of the Double type!" tempS soundUkr) --- | Function that removes all the sounds with ".raw", ".wav", ".ogg", ".flac" extensions in the current directory. It is used for --- the security reasons.-cleanCreatedSoundFs :: IO ()-cleanCreatedSoundFs = do- dirCs <- listDirectory "."- let remFs = concatMap (\ys -> filter (\zs -> ys `isSuffixOf` zs) dirCs) [".raw", ".wav", ".ogg", ".flac"] in mapM_ removeFile remFs---- | Function that repeatedly proposes and creates if accepted the sound records with the new \"voice\". Besides it can play the newly created file once.-createAndPlayFs :: IO ()-createAndPlayFs = do - putStrLn "Next file can be now voiced by your \"voice\". If you would like to run a new round and create a new speech, enter \"y\" as text input now!"- putStrLn "Otherwise, the program will end and remove all your sound files in the current directory created with your voice during the program execution time."- choice <- getLine- if take 1 choice == "y"- then do- main6Ukr- createAndPlayFs- else return ()- --- | Function that proposes and creates if accepted the sound record with the new \"voice\". Besides it can play the newly created file once. It is used in the--- 'createAndPlayFs' function internally and recursively.-main6Ukr :: IO ()-main6Ukr = bracketOnError (do- putStrLn "Please, specify the arguments to control the output speech file! "- putStrLn "See https://hackage.haskell.org/package/mmsyn6ukr-0.6.0.0/docs/UkrainianLControl.html#v:genControl for more information."- putStrLn "You can specify e. g. \"o9-1\" or \"o5-1\" or other options."- arg <- getLine- let args = take 1 . words $ arg in do - putStrLn "Please, specify the name of the resulting sound file! Please, do NOT use '}' character and space or control characters!"- nameOfSoundFile <- getLine- let nameSF = filter (\x -> not (isSpace x) && not (isControl x) && x /= '}') nameOfSoundFile in- return (args, nameSF)) (\(args, nameSF) -> do- putStr $ "Notice, there was (may be) CmdLineArgument exception. To avoid it, please, specify the command line argument (if needed) in the form \"ABC\""- putStrLn $ " where A is either a letter \'f\', \'o\', \'w\' or a digit and B and C are both digits! The exception (may be) arose from the command line arguments " - ++ show args ++ " for the file: " ++ show nameSF ++ ". Please, check also whether the SoX was installed with the support for needed codec.") (\(args, nameSF) -> do - xs <- getContents- let ys = take (nSymbols (let zs = take 1 args in if null zs then [] else fst . genControl . head $ zs)) xs in - withBinaryFile (nameSF ++ ".raw") AppendMode (appendS16LEFile (convertToProperUkrainian ys))- putStrLn "The .raw file was created by the program. It will be processed further. "- let ts = fromJust (showE "sox") in do- _ <- readProcessWithExitCode ts ["r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", - fst . snd . genControl . concat $ args, nameSF ++ (snd . snd . genControl . concat $ args)] ""- removeFile $ nameSF ++ ".raw"- putStrLn "Would you like to play the resulting file now?"- pls <- getLine- if take 1 pls == "y" || take 1 pls == "Y" - then playA $ nameSF ++ (snd . snd . genControl . concat $ args)- else return ())+-- | Function 'cleanTemp' removes all the intermediate temporary files in the directory where it is called from.+cleanTemp :: IO ()+cleanTemp = do+ filenames <- getDirectoryContents =<< getCurrentDirectory+ let rems = filter (\x -> head x `elem` (['2'..'9'] ++ "_" ++ "x")) filenames in mapM_ removeFile rems
README view
@@ -6,10 +6,12 @@ The program starts with Caution to be responsible for usage and to use it personally. Then the program guides you through the creating and using your Ukrainian "voice". -Please, use it carefully. After the execution the program if -terminated naturally without interruption removes (cleans) +Please, use it carefully. After the execution you can+execute mmsyn7h program to produce some records with your +newly created "voice". During the execution of the last one+you can choose whether to remove (clean) all the created sound files in the current directory for -security reasons. If it terminates by interruption or in +security reasons. If the programs terminate by interruption or in general it is a good practice to remove the current directory sound files manually. @@ -26,9 +28,9 @@ duration of the sounds. They are then precessed by the SoX binaries already installed in the system to produce the needed sounds and then you can pronounce some Ukrainian text -with your recorded "voice". Nevertheless, you can substitute -whatever sounds you like (consider being sensible) instead of -your own voice.+with your recorded "voice" using mmsyn7h program. Nevertheless, +you can substitute whatever sounds you like (consider being +sensible) instead of your own voice. Be aware that if somebody can get access to the sounds of your voice or to the recorded speech (except you) then this
SoXBasics.hs view
@@ -158,12 +158,6 @@ removeFile $ "3" ++ file else error "SoX is not properly installed in your system. Please, install it properly and then call the function again." --- | Function 'cleanTemp' removes all the intermediate temporary files in the directory where it is called from.-cleanTemp :: IO ()-cleanTemp = do- filenames <- getDirectoryContents =<< getCurrentDirectory- let rems = filter (\x -> head x `elem` (['2'..'9'] ++ "_" ++ "x")) filenames in mapM_ removeFile rems- -- | Function 'recA' records audio file with the given name and duration in seconds recA :: FilePath -> Double -> IO () recA file x = if isJust (showE "rec")
− UkrainianLControl.hs
@@ -1,66 +0,0 @@--- |--- Module : UkrainianLControl--- Copyright : (c) OleksandrZhabenko 2019--- License : MIT------ Maintainer : olexandr543@yahoo.com------ A program and a library that can be used as a musical instrument synthesizer or for Ukrainian speech synthesis --- especially for poets, translators and writers. -----module UkrainianLControl (- -- * Control the program- genControl,- -- * Security and Limits- nSymbols-) where--import Data.Char (isDigit)-import qualified Data.Vector as V (generate)-import CaseBi (getBFst')---- | Function that converts the first digit in the command line argument (starting the argument or being the second one after the letter character) given, --- which is a digit in the range @[0..9]@ (providing an ascending approximately exponential scale with a basis of 10 starting from 2 and ending at 1000000001), --- to the upper bound of number of symbols that the 'main' function of the @mmsyn6ukr@ executable reads from the 'System.IO.stdin' for sounding.--- The default resulting value (no input) is 31416. If there is another first command line argument then the program --- terminates with the informational message. Using the command line argument is done for the security reasons: --- because of performative writing to the resulting file(s) there is a need to limit the used memory. For most cases it is--- enough to use the default value. If you have enough resources and a large Ukrainian text amount then specify the higher values --- (5 or a greater one). -nSymbols :: String -> Int-nSymbols xs | null xs = 31416::Int- | otherwise = getBFst' (31416::Int, V.generate 10 (\n -> (n, (10^n + 1)::Int))) (let temp = read xs::Int in if temp <= 9 && temp >= 0- then temp - else error "Please, specify a digit as a command line argument for the program!")---- | Function that prepares arguments for the controlling functions for the executable @mmsyn6ukr@. It takes a first command line argument and makes --- an analysis to produce a set of String. The first resulting String is an argument to 'nSymbols' function, the first in the inner tuple is an argument--- to the compression level for the comressed formats and the last one is the resulting file extension. The default value (no command line arguments) is--- @("", ("", ".wav"))@. Please, specify the command line argument (if needed) in the form \"ABC\""--- where A is either a letter \'f\', \'o\', \'w\' or a digit and B and C are both digits (or something equivalent, see below). --- --- Their meaning:--- --- A:--- --- \'f\' -> native FLAC format with compression from 0 (least) to 8 (best compression ratio) specified by the third characters; \'9\' is equivalent to \'8\'. This format is optional so, --- please, check whether it is supported by your SoX binaries. If no, install the SoX with support for the format. For more information, please, refer to the @sox@ documentation.--- --- \'o\' -> Ogg Vorbis format with compression from -1 (best) to 10 (least) specified by the characters after the first two characters. The default value is "-1". This format is optional --- so, please, check whether it is supported by your SoX binaries. If no, install the SoX with support for the format. For more information, please, refer to the @sox@ documentation.--- --- \'w\' -> WAV format with two options for bitrate - 11025 if the third character is less than '5' and greater than '0' and otherwise 22050 (the default one also for no command line arguments). --- --- If A is a digit, then it is used accordingly to 'nSymbols' function and SoX (if properly installed) quickly converts the .raw file to the default .wav with 22050 Hz bitrate.--- --- To obtain the best compression ratio, please specify something like \"o9-1\" or \"o5-1\" (or similar). For the best lossless compression - \"f98\" or \"f58\" (or similar). --- --- For more information, please, see the @sox@ manuals (e. g. for @soxformat@).-genControl :: String -> (String, (String, String))-genControl (x:xs) | x == 'f' = ([head xs], ("-C" ++ (if (compare (tail xs) "9" /= GT) && (compare (tail xs) "0" /= LT) then take 1 . tail $ xs else "8"), ".flac"))- | x == 'o' = ([head xs], ("-C" ++ (if ((compare (tail xs) "9" /= GT) && (compare (tail xs) "0" /= LT)) then take 1 . tail $ xs else if (tail xs == "10") then "10" else "-1"), ".ogg"))- | x == 'w' = ([head xs], ("-r" ++ (if ((compare (tail xs) "4" /= GT) && (compare (tail xs) "0" /= LT)) then "11025" else "22050"), ".wav"))- | isDigit x = ([x], ("", ".wav"))- | otherwise = ("", ("", ".wav"))-genControl [] = ("", ("", ".wav"))
mmsyn7ukr.cabal view
@@ -2,9 +2,9 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: mmsyn7ukr-version: 0.2.1.0-synopsis: A simple basic interface to some SoX functionality or to produce a close to the proper Ukrainian speech (if you pronounce sounds properly) with your own recorded voice.-description: A program and a library that can be used as a simple basic interface to some SoX functionality or to produce a close to the proper Ukrainian speech (if you pronounce sounds properly) with your own recorded voice.+version: 0.3.0.0+synopsis: A simple basic interface to some SoX functionality or to produce a voice that can be used by mmsyn7h+description: A program and a library that can be used as a simple basic interface to some SoX functionality or to produce a close to the proper Ukrainian sounds for speech (if you pronounce them properly) with your own recorded voice. homepage: https://hackage.haskell.org/package/mmsyn7ukr license: MIT license-file: LICENSE@@ -17,10 +17,10 @@ cabal-version: >=1.10 library- exposed-modules: UkrainianLControl, SoXBasics, Processing_mmsyn7ukr, Main+ exposed-modules: SoXBasics, Processing_mmsyn7ukr, Main -- other-modules: -- other-extensions:- build-depends: base >=4.7 && <4.14, process >=1.4 && <1.8, vector >=0.11 && <0.14, mmsyn2 >=0.1.7 && <1, directory >=1.2.5 && <1.4, mmsyn6ukr >=0.6.1 && <1, mmsyn3 >=0.1.4 && <1+ build-depends: base >=4.7 && <4.14, process >=1.4 && <1.8, vector >=0.11 && <0.14, bytestring >=0.10 && < 0.12, mmsyn2 >=0.1.7 && <1, directory >=1.2.5 && <1.4, mmsyn6ukr >=0.6.1 && <1, mmsyn3 >=0.1.4 && <1 -- hs-source-dirs: default-language: Haskell2010 @@ -28,6 +28,7 @@ main-is: Main.hs -- other-modules: -- other-extensions:- build-depends: base >=4.7 && <4.14, process >=1.4 && <1.8, vector >=0.11 && <0.14, mmsyn2 >=0.1.7 && <1, directory >=1.2.5 && <1.4, mmsyn6ukr >=0.6.1 && <1, mmsyn3 >=0.1.4 && <1+ build-depends: base >=4.7 && <4.14, process >=1.4 && <1.8, vector >=0.11 && <0.14, bytestring >=0.10 && < 0.12, mmsyn2 >=0.1.7 && <1, directory >=1.2.5 && <1.4, mmsyn6ukr >=0.6.1 && <1, mmsyn3 >=0.1.4 && <1 -- hs-source-dirs: default-language: Haskell2010+