Python Speech Libraries

View previous topic View next topic Go down

Python Speech Libraries

Post by jamied_uk on 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.

avatar
jamied_uk
Admin

Posts : 2022
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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