Automatically generate custom voice files

ersky9xr is the port of the er9x firmware to the 9XRPRO radio.
Post Reply
Quiddel
Posts: 8
Joined: Fri Jul 18, 2014 7:49 pm
Country: -

Automatically generate custom voice files

Post by Quiddel »

Hello there.

Today I fiddled a little bit to generate custom voice files compatible to the 9XR PRO using command line speech synthesis and command line format adaption on my Mac. Everything can be done in one script and no interaction (e.g. converting with Audacity) is required. The script is a little redundant but easier to understand that way.

Side note: I have not managed to find a 9XR PRO compatible format string for the say command. I use sox for the adaption, its free, lives in the command line and things like Audacity are also depending on it.

Addendum: Linux/Unix users might have to adapt things for the use of espeak instead of the say command for synthesis.

Maybe this would be useful to include in the respective manual for the 9XR PRO.

Prerequisites
  • You are using a serious OS (Unixoid like OS X or Linux). If your OS is rather funny (e.g. Win), feel free to add your solution or nag someone to run your script for you.
  • You have the "say" command installed (default on OS X, others eventually check their packet managers)
  • You have the chosen voice installed (check the respective system prefs on your Mac, I chose and installed Samantha)
  • On a Mac, you have homebrew installed. Google for the one command line installation instruction if not.
Steps
  • Install the program "sox" for the 9XR PRO compatible PCM format adaption. On a mac, thats

    Code: Select all

    brew install sox
    . Others check their packet managers.
  • Create a new script file and make it executable.

    Code: Select all

    touch script.sh && chmod +x script.sh
  • Edit your script file and include the following:

    Code: Select all

    #!/bin/sh
    
    # My model 1
    say -v samantha -o 0261_temp.wav --data-format=I16@22050 "MCPX"
    sox 0261_temp.wav -t wavpcm -e signed-integer 0261.wav
    
    # My model 2
    say -v samantha -o 0262_temp.wav --data-format=I16@22050 "Flame wheel 450"
    sox 0262_temp.wav -t wavpcm -e signed-integer 0262.wav
    
    # Add further tuples for each one of your models. The voice indices 0261 to 0399 should be available for custom messages.
    
    # Remove temp files
    rm 0*_temp.wav
    
  • Run your script.sh

    Code: Select all

    ./script.sh
  • Transfer the generated files to your SD card (card reader is less painful).
  • Set up each model with the respective voice index.
  • You could also regenerate and replace other voice files from the voice file index list in no time...
  • Have a beer.
For reference, see man say, man sox and man soxformat. The latter seems outdated, but the executable is nice enough to not only tell you about deprecations, but also handing you the new way.

Thanks for reading, yell at me for improvements/corrections and feel free to add your solution.

Quiddel
Posts: 8
Joined: Fri Jul 18, 2014 7:49 pm
Country: -

Re: Automatically generate custom voice files

Post by Quiddel »

I have fiddled some more and did a script that generates all the voice files using a list stored in a text file (; is the delimiter, whitespaces are ok).

Note: The source of the text is the index list file from the Correct SD Card thread. Some of the texts are descriptive (e.g. Welcome Message) instead of the actual wav file content (Welcome to the Turnigy 9XR PRO).

The IndexToTextMap.txt is done in a format such that it allows for adding columns for e.g. variants or different languages. If you choose another language, be sure to change the voice in the say command to one that was made for that language.

If anyone wants to contribute (e.g. languages) I propose that I put it on Github. That'll ease collaboration.

Rename the generator.txt to generator.sh if you are an esthete :).
Attachments
generate.txt
Wav file generator script
(628 Bytes) Downloaded 404 times
IndexToTextMap.txt
The texts to be spoken, taken from the original voice file index list.
(4.88 KiB) Downloaded 373 times
Quiddel
Posts: 8
Joined: Fri Jul 18, 2014 7:49 pm
Country: -

Re: Automatically generate custom voice files

Post by Quiddel »

I included a german translation. Was easy, most of it was done by the Google Translator.

When you use Excel to edit, you need to save as csv in the Windows format. The updated script will handle character conversion (only german umlauts tested so far).

The german language files are attached as an example.
Attachments
9XR_Pro_German_Language.zip
The result for the language german. In case you have no mac at hand.
(9.72 MiB) Downloaded 329 times
generate.txt
Updated generator script preconfigured to output german.
(949 Bytes) Downloaded 391 times
IndexToTextMap.csv
The same map file exported as Windows csv in excel (shitty encoding, but the script handles that at least for German umlauts)
(8.37 KiB) Downloaded 376 times
Last edited by Quiddel on Thu Jul 24, 2014 12:04 pm, edited 1 time in total.
Quiddel
Posts: 8
Joined: Fri Jul 18, 2014 7:49 pm
Country: -

Re: Automatically generate custom voice files

Post by Quiddel »

I added french using the Google Translator. I do not speak french, so this is totally unedited and for illustration purposes.
Attachments
IndexToTextMap.csv
*** Off by one in lower half of french column fixed *** The same map file exported as Windows csv in excel (shitty encoding, but the script handles that at least for german umlauts)
(11.37 KiB) Downloaded 412 times
9XR_Pro_French_Language.zip
The result for the language french. In case you have no mac at hand.
(9.18 MiB) Downloaded 379 times
generate.txt
Updated generator script preconfigured to output french.
(1021 Bytes) Downloaded 408 times
Last edited by Quiddel on Sun Jul 27, 2014 7:28 pm, edited 1 time in total.
User avatar
LTMNO
Posts: 1049
Joined: Fri Nov 30, 2012 9:31 pm
Country: Canada
Location: Toronto, Canada

Re: Automatically generate custom voice files

Post by LTMNO »

Very cool. Great work!
Custom 9x with M64/Telemetry Mod

Quiddel
Posts: 8
Joined: Fri Jul 18, 2014 7:49 pm
Country: -

Re: Automatically generate custom voice files

Post by Quiddel »

Thanks. For those of you that are interested in the french column: I had a off-by-one error beginning with row hundered (text) somewhere in the middle. I have fixed it and updated the post accordingly, so be sure to get the latest cvs file.

Post Reply

Return to “ersky9xr”