-
Notifications
You must be signed in to change notification settings - Fork 0
Text to Speech
Mark Niemann-Ross edited this page Jan 9, 2017
·
8 revisions
Text-to-speech on the fish involves several steps:
- Obtain a string to speak
- Convert the string to an audio file
- Play the audio file
These steps should happen asynchronously. That is:
- Any program, at any time, should be able to request speech
- Converting text to an audio file shouldn't block anything else
- Playing back the sound should be FIFO. The second sound in the queue shouldn't play until the first is finished.
- There should be a way to dump the queue or set a priority. (to come if necessary)
To implement this, I'm going to try SQLite. A record will look like:
- UID - unique id
- creation date of record - second sort
- priority - first sort
- string to be spoken
- BLOB - wav file to be spoken
The process is broken into three parts:
-
bmbb_fish.fishSays
- queue speech requests to SQLite. Two arguments: priority and phrase -
do_TTS.py &
- sweeps SQLite for phrases that need to be converted to audio, handles the conversion, then inserts the BLOB into the record -
speakNextPhrase.py &
- pulls the next phrase from SQLite and plays it. When that phrase is finished, delete it from SQLite and get the next phrase. If there are no phrases to speak, then wait until there are.
sudo apt-get install espeak
If you are using python 2
wget https://pypi.python.org/packages/source/p/pyttsx/pyttsx-1.1.tar.gz
gunzip pyttsx-1.1.tar.gz
tar -xf pyttsx-1.1.tar
cd pyttsx-1.1/
sudo python setup.py install
If you are using python 3
sudo apt-get install python3-pip (this may not be necessary python)
sudo pip install pyttsx
or
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python3
wget https://pypi.python.org/packages/source/p/pyttsx/pyttsx-1.1.tar.gz
gunzip pyttsx-1.1.tar.gz
tar -xf pyttsx-1.1.tar
cd pyttsx-1.1/
sudo python3 setup.py install