module Main where
import System.IO
import DobutokO.Poetry (uniq10Poetical4,uniq10Poetical5)
import System.Environment (getArgs)
import Melodics.Executable (recFileName, printInfoF, rawToSoundFile)
import Melodics.Ukrainian (appendS16LEFile, convertToProperUkrainian)
import EndOfExe (showE)
import Data.Maybe (fromJust,isJust)
main :: IO ()
main = do
args <- getArgs
let arg0 = concat . take 1 $ args
word1s = unwords . drop 1 $ args
if arg0 == "4" then uniq10Poetical4 word1s else uniq10Poetical5 word1s
putStrLn "What string would you like to record as a Ukrainian text sounding by mmsyn6ukr package? "
str <- getLine
nameAndRec str
nameAndRec :: String -> IO ()
nameAndRec str = do
name <- recFileName
withBinaryFile (name ++ ".raw") AppendMode (appendS16LEFile (convertToProperUkrainian str))
putStrLn "The .raw file was created by the program. If there is SoX installed then it will run further. "
let ts = showE "sox"
if isJust ts
then rawToSoundFile "" name (fromJust ts)
else printInfoF