Pyttsx isn’t showing installed languages on windows 10
Asked Answered
S

2

5

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?

Skein answered 24/6, 2019 at 6:26 Comment(0)
S
8

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.

  1. Open regedit.exe (Windows + R, and type regedit) and navigate to the Registry key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCore\Voices\Tokens.

  2. Right click on the voice you want to use and chose export.

  3. Open the exported file with a text editor (for example Notepad++).

  4. 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).

  5. In the first part of the data, replace \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCore\Voices\Tokensby HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens (you have to do this at two distinct places).

  6. 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).

  7. Save the file, close it, and double click it. Accept the registry modification.

  8. Restart your computer.

Now the exported voices are available to use with pyttsx3!

Skein answered 24/6, 2019 at 8:52 Comment(1)
This is an incredible solution! It worked for me, especially after changing the format of the name of the language in the registry from the OneCore structure to the old structure, i.e. TTS_MS_[locale]-[lang]_[voice name]_11.0Darryl
P
5

Easier way without using Registry directly is to use Window Powershell (run as administrator) to do the same thing as the answer of Silver Duck. Copy and paste the code below into Powershell:

$sourcePath = 'HKLM:\software\Microsoft\Speech_OneCore\Voices\Tokens' #Where the OneCore voices live
$destinationPath = 'HKLM:\SOFTWARE\Microsoft\Speech\Voices\Tokens' #For 64-bit apps
$destinationPath2 = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens' #For 32-bit apps
cd $destinationPath
$listVoices = Get-ChildItem $sourcePath
foreach($voice in $listVoices)
{
$source = $voice.PSPath #Get the path of this voices key
copy -Path $source -Destination $destinationPath -Recurse
copy -Path $source -Destination $destinationPath2 -Recurse
}

References:

Pyongyang answered 11/1, 2022 at 15:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.