PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Python Speech Libraries

Go down

Python Speech Libraries Empty Python Speech Libraries

Post by jamied_uk 11th January 2016, 15:48

sudo pip install pyttsx
Create the code speech1.py
import pyttsx
engine = pyttsx.init()
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

1
2
3
4
import pyttsx
engine = pyttsx.init()
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

And execute it with python.
Espeak
eSpeak is a compact open source software speech synthesizer for English and other languages, for Linux and Windows.  We can install using:
sudo apt-get install espeak
1sudo apt-get install espeak

Create the code speech2.py:
import os
os.system("espeak 'The quick brown fox'")

1
2
import os
os.system("espeak 'The quick brown fox'")

It is very easy to use, but like pyttsx it sounds very robotic.
GoogleTTS
I found a script on Github that uses the Google speech engine.  The script comes with many options and does not speak, instead it saves to an mp3. We added a command to play the mp3 automatically:
os.system("mpg321 out.mp3 -quiet")
1os.system("mpg321 out.mp3 -quiet")

Run with:
python gtts.py -s 'Python programming example'
1python gtts.py -s 'Python programming example'

The voice is extremely natural. The only disadvantage is that you need to be connected with the Internet when running this script.
 Conclusion
GoogleTTS is the most natural speech synthesis engine that we found. While other TTS engines are simple to use they simply do not match the sound quality.  Sadly the number of available voices is limited.

jamied_uk
jamied_uk
Admin

Posts : 2950
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum