Revisiting "faster telemetry" for ASL3

Revisiting this topic since the last posts I see on it are over 10 years old. Is there any faster/easier way to speed up telemetry these days?

In another topic, someone posted a script that recursively speeds up all the sound files using the tempo function of SoX. IIRC, it had a couple of problems, mainly that it did silence reduction after, not before time compression, which caused some weird behavior. I've been meaning to look at that and optimize it more, for example, silence reduction on both of the start and end, not just the start, and changing the order of trimming silence and time compression. Would probably also be a good idea to copy the entire tree to a custom directory and enable the custom sound flag so that it doesn't get nuked during Package updates.

I wish we could just farm all the telemetry messages out to a local TTS engine. Would make it easier to customize strings and make things flow better. It would also be much easier to replace the voice, if you, like many of us, don't like Allison. This currently involves replacing lots of pre-recorded samples.

Ya I replaced all the files once in ASL2 and it was great having it faster. I'm not at all interested in the script/steps/issues you mentioned. That would be nice to use a TTS engine and be able to just specify variables like speed, voice, etc.

Hey I just found this by accident! ASL3 DOES have ability to access a TTS engine! I don't know if it could be used for telemetry but here is the info for the more proficient users out there to study- ASL Text-to-Speech - AllStarLink Manual

I tried it but get a permissions error but don't know where the "running directory" is located-

root@ASL48654:/home/kk6qms# sudo -u asterisk asl-tts -n 63001 -t 'Good morning'
Unable to access the running directory (Permission denied). Changing to '/' for compatibility.

ASL Text-to-Speech

ASL provides the asl-tts command. This is a text to speech speaker for ASL3. It uses the piper open source TTS system that is not dependent on cloud providers and has opensource voice models for dozens of languages.

If the asl-tts command doesn't exist on your system, you will need to install the asl3-tts package:

sudo apt install asl3-tts

Basic Operation

asl-tts uses the piper-tts text to speech engine to generate ulaw files from text so that Asterisk/apt_rpt can speak any set of arbitrary text without needing to have a sound file installed for the word necessary. By default, asl-tts will cause app_rpt to immediately speak whatever text was specified.

asl-tts has a time delay

Running the piper-tts system takes a few seconds to compile the voice into the sound file. Larger text blocks may take tens of seconds to compile. asl-tts is not appropriate for time-sensitive communications such as speaking the current time.

The command format is as follows:

sudo -u asterisk asl-tts -n <node> -t 'TEXT' [ -v <voice> ] [ -f <file> ]

The general use case is to speak to a node immediately. This this case speaking the text "Good morning" to node 63001 would look like this:

sudo -u asterisk asl-tts -n 63001 -t 'Good morning'

The TTS engine will start, create the audio, and execute the playback on the node. The playback follows normal app_rpt rules and will be played back as soon as its turn arrives. The command will not preempt or "talk over" other traffic on the node.

Keep in mind the differences between quoting in a shell command. In general, the " and ' work the same but the double-quote will allow variable substitution while the single quote will not. This can be useful if you want to create text based on a system condition. For example:

TODAY=$(date +"%A, %B %d, %Y")
sudo -u asterisk asl-tts -n 63001 -t "Today is ${TODAY}"

Obviously the above example is a bit contrived as the date command doesn't generate nice words such as "first", "seventeenth", etc. However, it demonstrates the flexibility of the tool. A script could be used to populate $TODAY with natural words. For a hypothetical example:

TODAY=$(/path/to/today-script)
sudo -u asterisk asl-tts -n 63001 -t "Today is ${TODAY}"

More complex message can be created with additional shell coding. As an example here's how the current public IP address of the system could be obtained and spoken:

IPADDR=$(wget -q -O - checkip.dyndns.com | grep -Po "[\d\.]+" | sed 's/\./ dot /g')
MSG="The node public IP is ${IPADDR}"
sudo -u asterisk asl-tts -n 63001 -t ${MSG}

A bash shell variable can generally hold up to a 2 Mb-sized string so any reasonably-formatted text can be stored in a variable and then played with the -t command. Keep in mind that the text or the variable contents must not contain the same quote type used in the command without escaping it with a backslash. For example "Nested \" mark".

Temporary File Cleanups

Note that temporary files are written to directories named /tmp/asl-tts* and are not automatically cleaned up because it's impossible to know when Asterisk will actually need/speak the file contents. If this becomes a space problem, put in a systemd timer unit or a cron job to delete old files in /tmp/asl-tts*. The command can simply be rm -rf /tmp/asl-tts*.

Creating a Sound File for Later

To create the text for other usage, such as cron jobs, use the -f FILE option to specify where the file should be created. Do not use an extension, the file will be automatically appended with the .ul suffix.

For example:

AUD_TEXT="The club net will begin in five minutes!"
sudo -u asterisk asl-tts -n 460181 -t "${AUD_TEXT}" -f /tmp/netstartsin5

This will create a sound file /tmp/netstartsin5.ul that can be used later with an asterisk playback such as:

asterisk -rx 'rpt playback 63001 /tmp/netstartsin5

Note that -n is required but irrelevant to this use case.

Voices

By default, the package provides the voice "Amy" from piper/VOICES.md at master · rhasspy/piper · GitHub . This voice is the closest voice to the default Asterisk and app_rpt sounds ("Allison"). It is possible to download other voices, for any language, and store the .onnx and .onxx.json files in /var/lib/piper-tts and then use them with the -v option. For example, to add the English (en_GB) voice "Alan" from the voices repository:

  1. Download the .onnx and .onnx.json file to /var/lib/piper-tts

  2. Specify -v en_GB-alan-low.onnx on the command line to asl-tts. As an example:

sudo -u asterisk asl-tts -n 63001 -v en_GB-alan-low.onnx -t "Good morning"

File Quality

Since all files are squashed down to 8K uLaw format, there is no value in the "medium" or "high" quality models. Always use the "low" quality model.