First install festival and a default voice
sudo apt-get install festival festvox-kallpc16k
Check to make sure your sound is working Then... you can test that it's working by typing
echo "I am not a robot" > festival_test
festival --tts festival_test
You should hear festival respond in a robotic voice with the words "I am not a robot"
Next we will need a way of returning selected text to festival so it knows what to read To do this we will use a program called xsel
Install xsel with
sudo apt-get install xsel
Next we need to creat a bash script to execute. We can do that with
cat << eof > text_to_speech.sh
#!/bin/bash
xsel | festival --tts --pipe
eof
We will also need to make it executable
chmod +x text_to_speech.sh
Now go to your keyboard shortcuts and select a custom keybinding and point it at that script for example I use Alt+space and I point the binding at the following path "/home/YOUR_USER_NAME_HERE/text_to_speech.sh"
Fin
Thanks to these sources https://www.youtube.com/watch?v=4uKTamXonPs http://wisercoder.com/install-festival-text-speech-ubuntu/