I'm using TTS in python. (pyttsx library). I read in documentation that I can get properties rate, voice, voices, volume. In documentation is only about that I can set property only for rate, voice, volume. It means that I can't set properties "voices"? I'm interested in voices, because it contains age, gender, languages etc. documentation here: http://pyttsx.readthedocs.io/en/latest/engine.html#pyttsx.voice.Voice
I can use rate, voice, volume easly for example:
engine = pyttsx.init()
engine.getProperty('rate')
engine.getProperty('volume')
engine.setProperty('rate', 50)
engine.setProperty('volume', 0.25)
engine.say("something")
engine.runAndWait()
The question is. Is there a chance to change "gander", "age" or "language" of speaking voice? If there is, please give me an example of how to do it, because I'm totally out of ideas.
There is an example of using voices.id, which is inside voices actually, but it didn't helped me out:
engine = pyttsx.init()
voices = engine.getProperty('voices')
for voice in voices:
engine.setProperty('voice', voice.id)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
sorry for bothering you, thanks :-)
I hope this helps. I also use pyttsx, with Python on a win7 os, and I am working on a small AI, with pyttsx as the voice output.
The pyttsx voice selection class works well with SAPI5 voices, found here; From the start button, type and run regedit.exe 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\'
Win7 comes packaged with just 1 voice(MS-Anna)
At microsoft there are more to choose from; http://www.microsoft.com/en-us/download/details.aspx?id=27224
MSSpeech_TTS_en-CA_Heather MSSpeech_TTS_en-GB_Hazel MSSpeech_TTS_en-IN_Heera MSSpeech_TTS_en-US_Helen MSSpeech_TTS_en-US_ZiraPro MSSpeech_TTS_en-AU_Hayley
However, you can also download and install eSpeak. Many SAPI5 voices may be installed during installation, and the install may be repeated as many times as you wish. There are good docs in the directory. With pyttsx, you can then directly select whichever voice you want to use. So to get to the SAPI5 voice ids found in the 'Tokens' directory
speech_engine = pyttsx.init()
voices = speech_engine.getProperty('voices')
for voice in voices:
print 'voice', voice.id
#speech_engine.setProperty('voice', voice.id)
#speech_engine.say('The quick brown fox')
# here I find I have installed just 1 eSpeak voice into the Tokens DIR;
anna_voice = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices\\Tokens\\MS-Anna-1033-20-DSK'
male_voice_1 = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices\\Tokens\\eSpeak'
#=====
rate = speech_engine.getProperty('rate')
# the rate should be signed + for faster or - for slower
speech_engine.setProperty('rate', rate-85)
#=====
volume = speech_engine.getProperty('volume')
speech_engine.setProperty('volume', volume+1.0)
#=====
def speak(input_text):
global talking_yes_or_no
i = ''
txt_list = list(input_text)
if len(txt_list) > 0:
for i in txt_list:
if i == '':
txt_list.remove(i)
txt = ''.join(txt_list)
if txt != "":
speech_engine.say(txt)
speech_engine.runAndWait()
#=====
def use_anna_voice():
speech_engine.setProperty('voice', anna_voice)
#=====
def use_male_voice_1():
speech_engine.setProperty('voice', male_voice_1)
#=====
#use_male_voice()
#speak('hello')