Lubos Rendek

The only solution is determination.

TEXT to SPEECH Bash Script With Google Translator

| Comments

Today we have had a little bit of fun with my daughter as she came back from a pre-school with a homework. This was a first homework she had and it was about learning new letters and simple written words. To make this activity more fun I have created a simple script which will simply read and say anything typed on the command line. It turned out to be a great idea as she started to type various words, letters and numbers into the terminal and repeating after. To enhance this experience I recommend to turn on virtual keyboard as your kid may have a trouble to distinguish between uppercase and lowercase letters. This way they either can use virtual keyboard with mouse or keyboard. Here is the simple bash script:

1
2
3
4
5
6
7
8
#!/bin/bash


while read word; 
do 
wget -q -U Mozilla -O output.mp3 "https://ssl.gstatic.com/dictionary/static/sounds/de/0/$word.mp3" 
mplayer output.mp3 &> /dev/null
done 

save this code into some arbitrary file like speak.sh and execute:

1
2
3
4
5
bash speak.sh
hello
12
a
how are you?

the script will repeat anything you type, whether it is a single letter, number, word or sentence etc. To exit this script enter CTRL+C . Have fun…!

Comments