summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.md3
-rw-r--r--MMSyn7h.hs192
-rw-r--r--README34
-rw-r--r--mmsyn7h.cabal2
4 files changed, 136 insertions, 95 deletions
diff --git a/ChangeLog.md b/ChangeLog.md
index 77bc28b..d4fc28a 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -51,4 +51,7 @@ case and does not remove any resulting sound files.
* Fourth version revised D. Fixed issues with package not being compiled.
Improved informational messages.
+## 0.5.0.0. -- 2020-01-14
+* Fifth version. Added more command line options like "-h" and "-v". New module
+dependencies. Fixed issues with the deprecated wrong documentation.
diff --git a/MMSyn7h.hs b/MMSyn7h.hs
index 8c728ea..c0d4ab0 100644
--- a/MMSyn7h.hs
+++ b/MMSyn7h.hs
@@ -12,6 +12,7 @@
module MMSyn7h where
+import Control.Concurrent (myThreadId, killThread)
import Data.Char (isSpace, isControl)
import Data.Maybe (isJust, fromJust)
import System.IO
@@ -30,102 +31,127 @@ import System.Info (os)
import MMSyn7s (show7s)
-- | Function that proposes and creates if accepted the sound record with the new \"voice\". It plays the newly created file once. Then it can delete
--- the sound files in the current directory if you specified only one command line argument. If you specify the second command line argument \"s\"
--- and then a list of @String@ represented the Ukrainian sounds, then the program will use only these sounds representations additionally
--- to the default ones \"-.wav\", \"0.wav\" and \"1.wav\".
+-- the sound files in the current directory while being executed if the entered text starts with \"0\". If you enter as a first command line argument \"-h\",
+-- then the program prints informational message and is terminated (killed) successfully. If you specify as a first command line argument \"-v\", then
+-- the program prints its version number and is also successfully terminated. If you specify something else, the first command line argument is being treated as
+-- a name for the resulting file voiced. If you specify further command line arguments
+-- as a Ukrainian text, that contains only those sounds, which sound representations are in the current directory (you can create them by e. g. @mmsyn7ukr@ and @mmsyn7l@
+-- programs in the same name packages), then the program will use only these sounds representations additionally to the default ones \"-.wav\",
+-- \"0.wav\" and \"1.wav\" and produce the sounding for the text.
main7h :: IO ()
main7h = bracketOnError (do
dir <- getCurrentDirectory
putStrLn "You are now in the directory: "
putStrLn $ show dir
putStrLn ""
- putStrLn "You could specify the control parameters for the output speech file as the first command line argument to the running program mmsyn7h! "
+ putStrLn "You could specify a name of the resulting file and then the control parameters for the output speech file as the second command line argument to the running program mmsyn7h! "
putStrLn "See https://hackage.haskell.org/package/mmsyn6ukr-0.6.2.0/docs/UkrainianLControl.html#v:genControl for more information."
putStr "You could specify e. g. \"o9-1\" or \"o5-1\" (and the most compressed audio in the .ogg format will be produced) or other option. "
- putStrLn "If you have not specified the parameters and now would like to, please, terminate the running program and execute it again with the proper command line arguments. "
+ putStrLn "If you have not specified the name and the parameters and now would like to, please, terminate the running program and execute it again with the proper command line arguments. "
putStrLn ""
- putStr "If you specified the second command line argument as \"s\" and then provided as the further command line arguments a Ukrainian text, then the program will use only those "
- putStrLn "Ukrainian sounds representations, which were earlier produced for the sounds in the text. See further: https://hackage.haskell.org/package/mmsyn7s"
+ putStr "If you specified further command line arguments as a Ukrainian text, that contains only those sounds, which sound representations are in the current directory "
+ putStr "(you can create them by e. g. mmsyn7ukr and mmsyn7l programs in the same name packages), then the program will use only these sounds representations "
+ putStrLn "additionally to the default ones \"-.wav\", \"0.wav\" and \"1.wav\". See further: https://hackage.haskell.org/package/mmsyn7s"
putStrLn ""
args <- getArgs
- putStrLn "And now, please, specify the name of the resulting sound file! Please, do NOT use '}' character and space or control characters!"
- nameOfSoundFile <- getLine
- putStrLn ""
- 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
- let arg = take 1 args
- if (not . null . drop 2 $ args) && ((concat . drop 1 . take 2 $ args) == "s")
- then do
- putStrLn ""
- putStr "The resulting file will be played just after it is created by the program. "
- putStrLn ""
- let xs = unwords . drop 2 $ args
- ws = snd . genControl . concat $ arg
- ys = take (nSymbols (if null arg then [] else fst . genControl . head $ arg)) xs
- withBinaryFile (nameSF ++ ".raw") AppendMode (appendS16LEFileList (convertToProperUkrainian ys, show7s xs))
- putStrLn "The .raw file was created by the program. It will be processed further. "
- let ts = fromJust (showE "sox") in do
- _ <- readProcessWithExitCode ts (case fst ws of
- "" -> ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", nameSF ++ snd ws]
- _ -> ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", fst ws, nameSF ++ snd ws]) ""
- removeFile $ nameSF ++ ".raw"
- if take 5 os == "mingw"
- then do
- _ <- readProcessWithExitCode (fromJust . showE $ "sox") [nameSF ++ snd ws, "-t", "waveaudio", "-d"] ""
- return ()
- else if isJust . showE $ "play"
- then do
- _ <- readProcessWithExitCode (fromJust . showE $ "play") [nameSF ++ snd ws] ""
- return ()
- else error "SoX play is not installed properly in the system. Please, install it properly and execute the program again."
- else do
- putStrLn ""
- putStr "The resulting file will be played just after it is created by the program. To remove all the created sound files from the directory, "
- putStrLn "please, specify now the first character in the input as \"0\". Otherwise, the program will not remove any records (if they are not overwritten). "
- putStrLn ""
- putStrLn "Now enter the Ukrainian text."
- putStrLn ""
- xs <- getContents
- if take 1 xs == "0" then do
- let ys = take (nSymbols (if null arg then [] else fst . genControl . head $ arg)) (drop 1 xs) in
+ putStr "If you do not use the command line parameters \"-h\" or \"-v\", then you must have specified the file name for the resulting sound recording "
+ putStrLn "(do NOT use '}' character and space or control characters!). "
+ case (concat . take 1 $ args) of
+ "" -> error "Please, specify as a command line argument at least a name of the resulting file (without its extension)! "
+ "-h" -> do
+ putStrLn "Synopsis: "
+ putStrLn "mmsyn7h fileName [control parameter (see: genControl from mmsyn6ukr package)] [a Ukrainian text being one line to be voiced] OR"
+ putStrLn "mmsyn7h -h OR"
+ putStrLn "mmsyn7h -v"
+ putStr "If \"-h\" is specified, then you will see this message. If \"-v\" is specified, then you will see the version of the package mmsyn7h. "
+ putStrLn "If something else is specified then the program runs further. "
+ threadId <- myThreadId
+ killThread threadId
+ let nameSF = ""
+ return (args, nameSF)
+ "-v" -> do
+ putStrLn "mmsyn7h version 0.5.0.0."
+ threadId <- myThreadId
+ killThread threadId
+ let nameSF = ""
+ return (args, nameSF)
+ nameOfSoundFile -> do
+ let nameSF = filter (\x -> not (isSpace x) && not (isControl x) && x /= '}') nameOfSoundFile
+ putStrLn ""
+ 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
+ let arg = drop 1 . take 2 $ args
+ if (not . null . drop 2 $ args)
+ then do
+ putStrLn ""
+ putStr "The resulting file will be played just after it is created by the program. "
+ putStrLn ""
+ let xs = unwords . drop 2 $ args
+ ws = snd . genControl . concat $ arg
+ ys = take (nSymbols (if null arg then [] else fst . genControl . head $ arg)) xs
+ withBinaryFile (nameSF ++ ".raw") AppendMode (appendS16LEFileList (convertToProperUkrainian ys, show7s xs))
+ putStrLn "The .raw file was created by the program. It will be processed further. "
+ let ts = fromJust (showE "sox") in do
+ _ <- readProcessWithExitCode ts (case fst ws of
+ "" -> ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", nameSF ++ snd ws]
+ _ -> ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", fst ws, nameSF ++ snd ws]) ""
+ removeFile $ nameSF ++ ".raw"
+ if take 5 os == "mingw"
+ then do
+ _ <- readProcessWithExitCode (fromJust . showE $ "sox") [nameSF ++ snd ws, "-t", "waveaudio", "-d"] ""
+ return ()
+ else if isJust . showE $ "play"
+ then do
+ _ <- readProcessWithExitCode (fromJust . showE $ "play") [nameSF ++ snd ws] ""
+ return ()
+ else error "SoX play is not installed properly in the system. Please, install it properly and execute the program again."
+ else do
+ putStrLn ""
+ putStr "The resulting file will be played just after it is created by the program. To remove all the created sound files from the directory, "
+ putStrLn "please, specify now the first character in the input as \"0\". Otherwise, the program will not remove any records (if they are not overwritten). "
+ putStrLn ""
+ putStrLn "Now enter the Ukrainian text."
+ putStrLn ""
+ xs <- getContents
+ if take 1 xs == "0" then do
+ let ys = take (nSymbols (if null arg then [] else fst . genControl . head $ arg)) (drop 1 xs)
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
+ putStrLn "The .raw file was created by the program. It will be processed further. "
+ let ts = fromJust (showE "sox") in do
+ let ws = snd . genControl . concat $ arg
+ _ <- readProcessWithExitCode ts ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw",
+ fst ws, nameSF ++ snd ws] ""
+ removeFile $ nameSF ++ ".raw"
+ if take 5 os == "mingw"
+ then do
+ _ <- readProcessWithExitCode (fromJust . showE $ "sox") [nameSF ++ snd ws, "-t", "waveaudio", "-d"] ""
+ cleanCreatedSoundFs
+ else if isJust . showE $ "play"
+ then do
+ _ <- readProcessWithExitCode (fromJust . showE $ "play") [nameSF ++ snd ws] ""
+ cleanCreatedSoundFs
+ else error "SoX play is not installed properly in the system. Please, install it properly and execute the program again."
+ else do
let ws = snd . genControl . concat $ arg
- _ <- readProcessWithExitCode ts ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw",
- fst ws, nameSF ++ snd ws] ""
- removeFile $ nameSF ++ ".raw"
- if take 5 os == "mingw"
- then do
- _ <- readProcessWithExitCode (fromJust . showE $ "sox") [nameSF ++ snd ws, "-t", "waveaudio", "-d"] ""
- cleanCreatedSoundFs
- else if isJust . showE $ "play"
- then do
- _ <- readProcessWithExitCode (fromJust . showE $ "play") [nameSF ++ snd ws] ""
- cleanCreatedSoundFs
- else error "SoX play is not installed properly in the system. Please, install it properly and execute the program again."
- else do
- let ws = snd . genControl . concat $ arg
- ys = take (nSymbols (if null arg then [] else fst . genControl . head $ arg)) xs
- 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 (case fst ws of
- "" -> ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", nameSF ++ snd ws]
- _ -> ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", fst ws, nameSF ++ snd ws]) ""
- removeFile $ nameSF ++ ".raw"
- if take 5 os == "mingw"
- then do
- _ <- readProcessWithExitCode (fromJust . showE $ "sox") [nameSF ++ snd ws, "-t", "waveaudio", "-d"] ""
- cleanCreatedSoundFs
- else if isJust . showE $ "play"
- then do
- _ <- readProcessWithExitCode (fromJust . showE $ "play") [nameSF ++ snd ws] ""
- cleanCreatedSoundFs
- else error "SoX play is not installed properly in the system. Please, install it properly and execute the program again.")
+ ys = take (nSymbols (if null arg then [] else fst . genControl . head $ arg)) xs
+ 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 (case fst ws of
+ "" -> ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", nameSF ++ snd ws]
+ _ -> ["-r22050","-c1","-L","-esigned-integer","-b16", nameSF ++ ".raw", fst ws, nameSF ++ snd ws]) ""
+ removeFile $ nameSF ++ ".raw"
+ if take 5 os == "mingw"
+ then do
+ _ <- readProcessWithExitCode (fromJust . showE $ "sox") [nameSF ++ snd ws, "-t", "waveaudio", "-d"] ""
+ cleanCreatedSoundFs
+ else if isJust . showE $ "play"
+ then do
+ _ <- readProcessWithExitCode (fromJust . showE $ "play") [nameSF ++ snd ws] ""
+ cleanCreatedSoundFs
+ else error "SoX play is not installed properly in the system. Please, install it properly and execute the program again.")
-- | The function that actually produces a .raw file. The mapping table is given in the @Map.txt@ file, but the sound duration differs.
appendS16LEFile :: V.Vector String -> Handle -> IO ()
diff --git a/README b/README
index a512b5f..a1825e2 100644
--- a/README
+++ b/README
@@ -5,20 +5,32 @@ sound files in the current directory. This allows to change the
needed files and to produce them by some other means (e. g. by
mmsyn7ukr).
Besides, you can remove the created by mmsyn7ukr and mmsyn7h files
-while the last one is running, if you specified just one command line
-argument.
+while the last one is running.
-If you specify the second command line argument "s" and then
-String of the Ukrainian text, then
-the program will use only these sounds representations
-additionally to the default ones "-.wav", "0.wav" and "1.wav".
-To create the needed sound representations, please, execute
-mmsyn7s with the needed Ukrainian text to be sounded (being a
-command line arguments) and then use the resulting output as a third
-command line argument to the mmsyn7ukr program.
+The program mmsyn7h plays the newly created file once. Then it can delete
+the sound files in the current directory while being executed if the
+entered text starts with "0". If you enter as a first command line
+argument "-h", then the program prints informational message and
+is terminated (killed) successfully. If you specify as a first command
+line argument "-v", then the program prints its version number and is
+also successfully terminated. If you specify something else, the first
+command line argument is being treated as a name for the resulting
+file voiced. If you specify further command line arguments as a
+Ukrainian text, that contains only those sounds, which sound
+representations are in the current directory (you can create them
+by e. g. mmsyn7ukr and mmsyn7l programs in the same name packages),
+then the program will use only these sounds representations
+additionally to the default ones "-.wav", "0.wav" and "1.wav"
+and produce the sounding for the text.
For more information, refer to:
https://hackage.haskell.org/package/mmsyn7ukr
https://hackage.haskell.org/package/mmsyn7s
-
+https://hackage.haskell.org/package/mmsyn7l
In such a case the program will not delete the created resulting
sound files.
+
+If you do not specify the Ukrainian text as the third and the next command line
+arguments, then the resulting file will be played just after it is created
+by the program. To remove all the created sound files from the directory,
+please, specify now the first character in the input as "0". Otherwise,
+the program will not remove any records (if they are not overwritten).
diff --git a/mmsyn7h.cabal b/mmsyn7h.cabal
index 7b5e578..059f844 100644
--- a/mmsyn7h.cabal
+++ b/mmsyn7h.cabal
@@ -2,7 +2,7 @@
-- documentation, see http://haskell.org/cabal/users-guide/
name: mmsyn7h
-version: 0.4.1.0
+version: 0.5.0.0
synopsis: Produces a sound recording specified by the Ukrainian text.
description: A program and a library that are used with mmsyn7ukr (or separately) and are similar to mmsyn6ukr executable. The program uses the data files in the current directory instead of ones in the system defined directories. It reads Ukrainian text with the given by data files sounds.
homepage: https://hackage.haskell.org/package/mmsyn7h