I am trying to use pyttsx3 to say French text. However, only English is available.
Following the advice of How to change the voice in pyttsx3?, I tried to install the French speech pack as explained here https://support.office.com/en-us/article/how-to-download-text-to-speech-languages-for-windows-10-d5a6b612-b3ae-423f-afa5-4f6caf1ec5d3.
I restarted my computer and now have the French speech to text module installed and available under the “voice” menu in the windows settings. The test button works and I hear the test sample in French.
I tried to run the following code to see what pyttsx3 has available:
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
print(voice, voice.id)
engine.setProperty('voice', voice.id)
engine.say("Hello World!")
engine.runAndWait()
engine.stop()
However, I just get the following output:
<Voice id=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0
name=Microsoft Zira Desktop - English (United States)
languages=[]
gender=None
age=None> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0
What am I missing?
I found a workaround by doing what is described there: https://www.ghacks.net/2018/08/11/unlock-all-windows-10-tts-voices-system-wide-to-get-more-of-them/
Here is a summary of the steps I followed. It assumes that you already have downloaded the voice packs as in the original question.
Open regedit.exe
(Windows + R, and type regedit) and navigate to the Registry key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCore\Voices\Tokens
.
Right click on the voice you want to use and chose export.
Open the exported file with a text editor (for example Notepad++).
Copy all the text a second time in the file so you have everything two times (except the first line Windows Registry Editor Version 5.00
).
In the first part of the data, replace \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCore\Voices\Tokens
by HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens
(you have to do this at two distinct places).
In the second part (the one you pasted below), do the same but change for HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens
(again, two places to change).
Save the file, close it, and double click it. Accept the registry modification.
Restart your computer.
Now the exported voices are available to use with pyttsx3!