pyttsx3
pyttsx3 copied to clipboard
Unusable Female Voice.
import pyttsx3 engine = pyttsx3.init()
rate = engine.getProperty('rate') engine.setProperty('rate', 190)
voices = engine.getProperty('voices') engine.setProperty('voice', voices[2].id)
engine.say('Hello World') engine.runAndWait()
Greetings from Vancouver Island, Canada. Newbie question. Note that in the above code, I am only able to get a female voice by using a 2 as the id. One is muddled and unusable while even the '2' is questionable. Zero for male works perfectly.
I'm on a Mac, using Pycharm. Is anyone else having this issue or have a set of rate/pitch/voice parameters to get the best female possible?
Thanks in advance.
% python3
>>> import pyttsx3
>>> engine = pyttsx3.init()
>>> voices = engine.getProperty('voices')
>>> print("\n".join(f"{i:>2}: {voice.name}" for i, voice in enumerate(voices)))
On my Mac, there are 48 voices to choose from.
I am on Ubuntu, there are 69 voices, but none is female voice
pyttsx3 is an interface on top of multiple test-to-speech engines. https://pyttsx3.readthedocs.io/en/latest/support.html
For Linux, the actual voices are provided by http://espeak.sourceforge.net
Then pttsx3 is not showing all the voices options when voices = engine.getProperty('voices')
It shows only the languages as provided by $ espeak --voices=
on the terminal
Only after executing on terminal $ espeak --voices=en
we can see all available voices, and then we can engine.setProperty('voice', 'us-mbrola-1')
https://github.com/numediart/MBROLA
https://github.com/numediart/MBROLA-voices#mbrola-voices-database
us-mbrola-1
is a female voice but perhaps it requires a license.
I'll check these links, thanks, but could you put a few more words in your comments.
Just a little test, that seems to work (Ubuntu 20.04 LTS), having the mbrola files installed.
First, to list the mbrola
voices in espeak-ng
(you need to have mbrola
and the mbrola-*
voices installed:
$ espeak --voices=mb
Pty Language Age/Gender VoiceName File Other Languages
7 af --/M afrikaans-mbrola-1 mb/mb-af1
1 ar --/M arabic-mbrola-1 mb/mb-ar1
2 ar --/M arabic-mbrola-2 mb/mb-ar2
7 pt --/M brazil-mbrola-1 mb/mb-br1
...
7 tr --/F turkish-mbrola-1 mb/mb-tr2
7 tr --/M turkish-mbrola-1 mb/mb-tr1
5 en-us --/F us-mbrola-1 mb/mb-us1 (en 8)
5 en-us --/M us-mbrola-2 mb/mb-us2 (en 7)
5 en-us --/M us-mbrola-3 mb/mb-us3 (en 8)
7 es-vz --/M venezuala-mbrola-1 mb/mb-vz1 (es 8)
Testing it from the command line they work OK, both in speed and pitch
$ espeak -v mb-us1 -s 130 "Hello, how are you doing?"
This simple python script seems to work:
import pyttsx3
engine = pyttsx3.init()
engine.setProperty('rate', 130)
engine.setProperty('volume', 1.0)
engine.setProperty('voice', 'mb-us1')
engine.say(" Hello, how are you doing?")
engine.runAndWait()
engine.stop()
The mb-us1
voice is (according to the description) an "... American English female voice for Mbrola ..."
Using the python code, the rate seems OK, but the pitch is too high. The voice sounds a bit like a chipmunk :-), still had not figured out how to fix that.
OK, there seems to be a patch for changing the pitch (ref: https://github.com/nateshmbhat/pyttsx3/commit/1e2cd7fc63671a410e6ca7b53b1e3b048577e962), but it is still not in a released version