mmsyn6ukr- A musical instrument synthesizer or a tool for Ukrainian language listening

Copyright(c) OleksandrZhabenko 2019
Safe HaskellNone




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.



main :: IO () Source #

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, .ogg, or .flac file with the same parameters specified by the first command line argument (for more details see: genControl function) using the system binary SoX. If it is not installed properly, the program makes ending informational message for the user.

Command line argument is described in more details in the documentation for the nSymbols function.

  • Notification.

Please, notice that successful usage of the SoX installed in the system prior to the mmsyn6ukr leads to approximately doubling the size of used space in the storage for the resulting files because it adds a header to the .raw file and writes down additionally the raw data to form a .wav file. Also notice that the size of the largest data file representing a symbol or their combination is 6792 bytes (with 44-byte header included). So, if you expect to create sounding for n symbols of the Ukrainian text, provide at least 2 * (6792 - 44) * n + 44 = 13496 * n + 44 (bytes) of the additional space in the storage (in reality it can occupy much less because other data files are less in size). Afterwards, the program deletes the .raw file (this will approximately halve the occupied space by the resulting file) and you can manually compress the .wav file (e. g. FLAC compression with the best ratio gives approximately halving the size. Therefore, the resulting file for the mmsyn6ukr executable run prior to such operations without command line arguments is expected to be less than about 10^7 bytes that is about 100 MB (for 31416 symbols Ukrainian text)). The best comression is with the .ogg files, but they can lose some quality so be careful if you need it.

Control the program

genControl :: String -> (String, (String, String)) Source #

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:


'f' -> native FLAC format with compression from 0 (least) to 8 (best compression ratio) specified by the third characters; '9' is equivalent to '8'. 'o' -> Ogg Vorbis format with compression from -1 (best) to 10 (least) specified by the characters after the first two characters; 'w' -> WAV format with two options for bitrate - 11025 if the third character is less than 5 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) converts the .raw file to the default .wav with 22050 Hz bitrate.

For more information, please, see the sox manuals (e. g. for soxformat).

Security and Limits

nSymbols :: String -> Int Source #

Function that converts the first command line argument 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 stdin for sounding. The default value (no input) is 31416. If there is another first command line argument then the program terminates with the error and 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).