Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RabbitsAndAstronauts/ffe0afc68558c208962861f39cae2442 to your computer and use it in GitHub Desktop.
Save RabbitsAndAstronauts/ffe0afc68558c208962861f39cae2442 to your computer and use it in GitHub Desktop.

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/

First install espeak

sudo apt-get install espeak

Check to make sure your sound is working Then... you can test that it's working by typing

echo "I am not a robot" > tts_test
espeak -f tts_test

You should hear espeak respond in a robotic voice with the words "I am not a robot"

Next we will need a way of returning selected text to espeak 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 | espeak --stdin
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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment