create your own custom sounds for Taranis X9D (Mac OS)

published : 2017-10-09 changed: 2017-10-09

category: Computer --> programming


Everybody who owns a Taranis X9D (or something similar) is familiar with this problem: the standard soundfiles are crap and the soundpacks available for the tarans can do a hell of a lot, but not what you need.

For example, right now you can configure your quad with the Taranis and LUA-Scripting via telemtetry. You can also configure your FC to have some of those functions on certain switches - which you do not have a proper soundfile for.

So, I thought we need to create our own soundpack. fortunately this is quite simple on MacOS. There is the command say which lets you run the text-2-speech system on the mac to say something. and this works from commandline! Awesome wonders of unix os! emoji people:smirk

say does take some options. with -v you define the voice to use and with -o you can define an output (aiff) file. That is cool, but the taranis cannot use aiff - you need to convert it.

If you did not install bew on your mac already, you should do that right now. With brew you get access to all those unix-tools that help us a lot on linux. So then you have access to ffmpeg which is able to convert aiff into wav as we need it - just be careful to use the right settings (32000hz, mono).

You need to do more or less the same, if you want to use your taranis as Music Player during flights.

I uploaded the script here! Attention: use at own risk! And: careful - the script will erase a folder called SOUNDS in the current directory! Please be careful!

in this file, you can define the voice quite at the beginning of the file:

#!/bin/bash

voice="Daniel"

#generate 1-100 first

rm  -rf SOUNDS
mkdir SOUNDS
mkdir  SOUNDS/en
mkdir  SOUNDS/en/SYSTEM
cd   SOUNDS/en/SYSTEM

sayToWav(){
        fn=$1
        txt=$2
        say  -v $voice -o $fn "$txt"
        ffmpeg  -i $fn.aiff -ar 32000 ;$fn.wav >/dev/null 2>&1 &
        echo -n "."
}

I use the voice "Daniel" which is an UK-English voice. But I like it, sounds quite cool.

If you have your taranis running with a different language than english, you will need to change the directories, especially rename en to the corresponding language code.

There you can see a bash function I created to crate a wav-File from text.

Attention: the aiff files are kept for a while as ffmpeg runs in the background for performance reasons. those files get deleted later.

With this function you can define your sounds. It takes 2 parametrs: the filename (without extension) and the text to say to that file.

echo "Generating system sounds..."

for in $(seq -f "%04g" 0 ;100); do
        n=$(echo $i | bc)
        sayToWav $i "$n"
done

sayToWav "101" "200"
sayToWav "102" "300"
sayToWav "103" "400"
sayToWav "104" "500"
sayToWav "105" "600"
sayToWav "106" "700"
sayToWav "107" "800"
sayToWav "108" "900"
sayToWav "109" "thousand"
sayToWav "110" "and"
sayToWav "111" "minus"
sayToWav "112" "point"

you should not change the files in the upper part of the script, as those create the system files needed by opentx to run smoothly.

At the end of the file, you can add custom texts which need to be created. I added here only a couple of values, most of them I really use in my setups:

cd ..
echo "Creating custom sounds"
###custom Sounds
## quads only
sayToWav acromd "acro mode"
sayToWav acro "acro"
sayToWav levelmd "level mode"
sayToWav level "level"
sayToWav stblzmd "stabelized mode"
sayToWav stblz "stabelized"

sayToWav beep_on "beeper on"
sayToWav beep_off "beeper off"
sayToWav vtx_hi "VTX high power"
sayToWav vtx_low "VTX low power"

sayToWav thract "throttle active"
sayToWav arm "quad armed"
sayToWav disarm "quad disarmed"

sayToWav eng_on "engines on"
sayToWav eng_off "engines off"

sayToWav thr_dis "throttle disabled"
sayToWav thr_rel "throttle release"
sayToWav idle_up "idle up"
sayToWav idle_dow "idle down"

sayToWav batlow "battery low"
sayToWav batcrit "battery critical"
sayToWav landnow "you should land now"
sayToWav batfail "battery failure imminent"
sayToWav timres "timer reset"

here you can add your stuff... whatever you like!

and here you can download the script!

Have lots of fun with it!

created Stephan Bösebeck (stephan)