Copyright 2016-2020 Sayak B. Licenced under GNU GPLv3.
You need to have eSpeak NG installed in your system and added to the path.
The latest installers for eSpeak NG can be found here.
The installed executable may need to be added to the system path. (See here)
sudo apt-get update
sudo apt-get install espeak-ngIf eSpeak NG is not available in your package manager, you may need to compile the binaries for your system. Refer to this page for more information.
This library is available on PyPi.
pip install espeakngYou can download the latest release for this library here.
First, we have to initialize a Speaker.
import espeakng
mySpeaker = espeakng.Speaker()And then use the Speaker.say() method to speak:
mySpeaker.say('Hello, World!')Calling Speaker.say() will interrupt any ongoing output from the same object
immediately.
Use the following code if you wish to wait for any ongoing speech to complete:
mySpeaker.say('I am a demo of the say() method.', wait4prev=True)By default the pitch is set at 80.
Change it by:
mySpeaker.pitch = 120By default WPM is set at 120.
Change it by:
mySpeaker.wpm = 140By default the voice is set to 'en'. The complete list of supported voices can be found here.
Change it by:
mySpeaker.voice = 'es'By default, your text will just be spoken aloud, but if you want it to be written to a .WAV file, you can specify an export_path when calling the say function, as seen below:
mySpeaker.say("Export this to a file", export_path="test.wav")- MickeyDelp for wordgap and amplitude controls, and other helper methods.
- FlorianEagox for the export to WAV file feature.