Saturday, November 6, 2010

Working with Liquidsoap's TTS

Yet another note to self which I'll sometime get around to adding to the wiki...

By default, the text-to-speech script that comes with the Liquidsoap audio scripting language is intentionally broke (uses "/bin/false" as the TTS tool!). The fix is easy:

- Edit /usr/local/lib/liquidsoap/0.9.3/liquidtts
- In the first line that starts with "echo", change the word "false" to "text2wave"

The next to the last line shouldn't need the word "false" changed to "text2wave". It's there in case the first part (before the first "return") fails.

And that's it. If you add say_metadata to your liq script, you should hear a familiar crappy synthesized voice, telling you what the song was.

If you want to use swift (i.e., Cepstral), the following seems to work well:

#!/bin/sh


# This script is called from liquidsoap for generating a file
# for "say:voice/text" URIs.
# Usage: liquidtts text output_file voice


swift -o $2.wav " that was $1 " && /usr/bin/sox $2.wav -t wav -c 2 -r 44100 $2 2> /dev/null > /dev/null
return=$?
/bin/rm $2.wav
false $2 2> /dev/null > /dev/null
exit $return

Please note that the first line of the script starts with "swift" and ends with "/dev/null > /dev/null".  Blogger likes to wrap code and cause problems.

I added in the "prosody" tags to slow Allison's speaking a bit. The default rate is set for "New Yorker". I've spent too much time in the South to be comfortable with it for any length of time.  If you want to tweak the voice further, Cepstral has some common usage examples.

I'm still trying to figure out how to get pass/accept events in and out for speech and for posting events to Twitter or IRC. The former probably means having to pull from a secondary stream. For the later, I'm pestering people (who said they had it working) for hints.

More reading required on my part, I guess.

No comments:

Post a Comment