packages feed

mmsyn7ukr 0.1.1.1 → 0.1.2.0

raw patch · 4 files changed

+71/−17 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Main: beginProcessing :: FilePath -> FilePath -> String -> IO ()

Files

ChangeLog.md view
@@ -10,4 +10,8 @@  ## 0.1.1.1 -- 2019-12-20 -* First version revised B. Imroved some documentation and .cabal file.+* First version revised B. Improved some documentation and .cabal file.++## 0.1.2.0 -- 2019-12-23++* First version revised C. Fixed an issues with the not created and not appripriately running recording for the sound.
Main.hs view
@@ -128,14 +128,17 @@           "S.wav", "T.wav", "U.wav", "V.wav", "W.wav", "X.wav", "Y.wav", "Z.wav", "a.wav", "b.wav", "c.wav",              "d.wav", "e.wav", "f.wav"] $ ["а", "б", "в", "г", "д", "дж", "дз", "е", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р",                 "с", "сь", "т", "у", "ф", "х", "ц", "ць", "ч", "ш", "ь", "і", "ґ"]) $ file1-  putStrLn $ "Listen to the \"" ++ soundUkr ++ "\" sound and note first of all its duration. "+  putStr "The needed files were not created, because the sound was not at the moment of recording! The process will be restarted "+  putStrLn "for the sound. Please, produce a sound during the first 3 seconds or specify larger ratio!"   playA file   longerK0 <- tempS soundUkr   (_, Just hout, _, _) <- createProcess (proc (fromJust . showE $ "soxi") ["-D", file]) { std_out = CreatePipe }   x3 <- hGetContents hout   let longerK = (read x3::Double)*longerK0   putStrLn $ "Please, now pronounce the sound representation of the " ++ soundUkr ++ " sound or whatever you would like to be substituted (be sensible, please)! "-  recA "x.wav" (7*longerK)+  if (compare (7*longerK) 3.0 == LT)+    then recA "x.wav" (7*longerK)+    else recA "x.wav" 3.0   putStrLn "The file is recorded and now will be automatically processed. You will be notificated with the text message in the terminal about the creation of the needed file. Please, wait a little. "   norm "x.wav"   noiseProfB "8x.wav"@@ -143,13 +146,53 @@   lim0 <- durationA "_8x.wav"   alterVadB "_8x.wav" lim0   lim1 <- durationA "7_8x.wav"-  alterVadE "7_8x.wav" lim1-  sincA "67_8x.wav"-  resampleA "4.67_8x.wav" (22050::Int)-  quarterSinFade "34.67_8x.wav"-  volS2 "434.67_8x.wav" file-  renameFile "8.434.67_8x.wav" file1+  if lim1 <= 0.0+    then beginProcessing file file1 soundUkr+    else do +      alterVadE "7_8x.wav" lim1+      sincA "67_8x.wav"+      resampleA "4.67_8x.wav" (22050::Int)+      quarterSinFade "34.67_8x.wav"+      norm "434.67_8x.wav"+      volS2 "8434.67_8x.wav" file+      renameFile "8.434.67_8x.wav" file1+      cleanTemp+      +-- | Function 'beginProcessing' is used to catch the variant where the sound is fully cut by the SoX because the sound was created in inappropriate time.+-- It returns the process to the beginning of the sound recording.+beginProcessing :: FilePath -> FilePath -> String -> IO ()+beginProcessing file file1 soundUkr = do   cleanTemp+  putStr "The needed files were not created, because the sound was not at the moment of recording! The process will be restarted "+  putStrLn "for the sound. Please, produce a sound during the first 3 seconds or specify larger ratio!"+  putStrLn $ "Listen to the \"" ++ soundUkr ++ "\" sound and note first of all its duration. "+  playA file+  longerK0 <- tempS soundUkr+  (_, Just hout, _, _) <- createProcess (proc (fromJust . showE $ "soxi") ["-D", file]) { std_out = CreatePipe }+  x3 <- hGetContents hout+  let longerK = (read x3::Double)*longerK0+  putStrLn $ "Please, now pronounce the sound representation of the " ++ soundUkr ++ " sound or whatever you would like to be substituted (be sensible, please)! "+  if (compare (7*longerK) 3.0 == LT)+    then recA "x.wav" (7*longerK)+    else recA "x.wav" 3.0+  putStrLn "The file is recorded and now will be automatically processed. You will be notificated with the text message in the terminal about the creation of the needed file. Please, wait a little. "+  norm "x.wav"+  noiseProfB "8x.wav"+  noiseReduceB "8x.wav"+  lim0 <- durationA "_8x.wav"+  alterVadB "_8x.wav" lim0+  lim1 <- durationA "7_8x.wav"+  if lim1 <= 0.0+    then beginProcessing file file1 soundUkr+    else do +      alterVadE "7_8x.wav" lim1+      sincA "67_8x.wav"+      resampleA "4.67_8x.wav" (22050::Int)+      quarterSinFade "34.67_8x.wav"+      norm "434.67_8x.wav"+      volS2 "8434.67_8x.wav" file+      renameFile "8.434.67_8x.wav" file1+      cleanTemp  -- | Function to get the @Double@ value, which shows in how many times you expect that your sound representation will be longer than the one provided by the @mmsyn6ukr@ package.  tempS :: String -> IO Double
SoXBasics.hs view
@@ -19,6 +19,7 @@ import System.Process import System.IO import EndOfExe+import System.Exit  -- | Function 'maxAbs' allows to choose a maximum by absolute value if the values are written as @String@. Bool @True@ corresponds to maximum value, @False@ - to minimum value maxAbs :: (String, String) -> (String, Bool)@@ -233,21 +234,27 @@     removeFile $ "8" ++ file   else error "SoX is not properly installed in your system. Please, install it properly and then call the function again." --- | Function 'volS2' changes the given audio (the first @FilePath@ parameter) with the linear ratio for the amplitude so that --- the resulting amlitude is equal to the maximum by absolute value amplitude for the file given by the second @FilePath@ parameter. --- The function must be used with the first @FilePath@ parameter containing no directories in its name (that mean the file of the first --- @FilePath@ parameter must be in the same directory that also the function is called from).+-- | Function 'volS2' changes the given audio (the first @FilePath@ parameter, which must be normalized e. g. by the 'norm' function before) with +-- the linear ratio for the amplitude so that the resulting amlitude is equal to the maximum by absolute value amplitude for the file given +-- by the second @FilePath@ parameter. The function must be used with the first @FilePath@ parameter containing no directories in its name +-- (that mean the file of the first @FilePath@ parameter must be in the same directory that also the function is called from). volS2 :: FilePath -> FilePath -> IO () volS2 fileA fileB = if isJust (showE "sox")    then do-    norm fileA     upp <- upperBnd fileB     amplMax <- selMA fileB (0, upp) True     amplMin <- selMA fileB (0, upp) False     let ampl = read (fst . maxAbs $ (amplMax, amplMin))::Double-    _ <- readProcessWithExitCode (fromJust (showE "sox")) ["8" ++ fileA, "8." ++ fileA, "vol", showFFloat Nothing ampl $ show 0, "amplitude", "0.01"] ""-    removeFile $ "8" ++ fileA+    (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [fileA, "8." ++ tail fileA, "vol", showFFloat Nothing ampl $ show 0, "amplitude"] ""+    if code /= ExitSuccess +      then error "File was not created with \"vol\" effect!"+      else do +        file8e <- doesFileExist $ "8." ++ tail fileA+        if file8e +          then removeFile fileA+          else error "Second error!"   else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."+          -- | Function 'sincA' uses a sinc effect with -a 50 -I 0.1k-11k band-pass filter for the audio file given. sincA :: FilePath -> IO ()
mmsyn7ukr.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mmsyn7ukr-version:             0.1.1.1+version:             0.1.2.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. homepage:            https://hackage.haskell.org/package/mmsyn7ukr