Speech engines with python tutorial
Python hosting: Host, run, and code Python in the cloud!
A computer system used to create artificial speech is called a speech synthesizer, and can be implemented in software or hardware products.
A text-to-speech (TTS) system converts normal language text into speech. How can we use speech synthesis in Python?
Related courses:Pyttsx
Pyttsx is a cross-platform speech (Mac OSX, Windows, and Linux) library. You can set voice metadata such as age, gender, id, language and name. Thee speech engine comes with a large amount of voices.
Text to speech sample:
Install with:
|
Create the code speech1.py
|
And execute it with python.
Espeak
eSpeak is a compact open source software speech synthesizer for English and other languages, for Linux and Windows.
Text to speech sample:
We can install using:
|
Create the code speech2.py:
|
It is very easy to use, but like pyttsx it sounds very robotic.
gTTS
The gtts module no longer works.
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:
|
Run with:
|
The voice is extremely natural. The only disadvantage is that you need to be connected with the Internet when running this script.
Links
You might like:
Leave a Reply:
How do i change the language in pyttsx from english to german? It would be great if you can send me some sample code for the same. Thanks in advance.
It depends on the driver, see available drivers on: https://github.com/RapidWareTech/pyttsx/tree/1a84ee33971951b1ea18f2708061a5d19ef94018/pyttsx/drivers
If you use Espeak you could try the setProperty method and set 'languages'