How do I add a voice / language to speechSynthesis?
Asked Answered
T

2

15

When I run speechSynthesis.getVoices() in Chrome, I get a list of possible voices. The list changes depending on the computer and version of Chrome.

Is there any way I can extend support and add more voices?

I feel like this could be done by asking a user to download a voice file for their chosen language. Do such files exist?

Edit:

This needs to work for both Windows and Mac computers.

It also needs to be simple, so no scripts or anything that would require extensive technical knowledge. I'm hoping for a "download and install" type of thing

Touchstone answered 19/11, 2017 at 17:21 Comment(0)
I
11

HOW TO ADD MORE VOICE FROM MICROSOFT EDGE TO CHROME AND FIREFOX ( only on windows 10 fall creator update or later)

you should using show list voice test first at: show available voice on browser

chrome have local and server voice, edge have local and can download more, firefox have nothing else but only 3 supported voice locked by windows registy.

Here's the script to unlock:

If your not sure how to run a powershell script:

Click Start

search for 'Powershell'

launch Powershell (Since this is editing a LocalMachine key, you will need to run as admin). Copy and paste the script into the console. Press enter.

$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
}

After running this on my Example machine and restarting, I have the following voices available to the api

Microsoft David Desktop; Microsoft Zira Desktop; Microsoft Zira Mobile; (Same as the desktop counterpart) Microsoft Mark Mobile;

I find these voices to be superior to the Desktop variants, plus variety is always nice

that you can test your new voice here after restart: show available voice on browser

here I can have 10 voices than 3 voices before, on firefox. That even I can install Vietnamese voice with Microsoft An from windows language, and my firefox can read vietnamese as edge. Microsoft An List voice

source reddit.com

Immunize answered 25/11, 2017 at 12:6 Comment(2)
Why / how does this work? Also I need something simpler and more universal. I can't ask users to write scripts. And most of my users are on MacTouchstone
I don't use Mac, sorry I can't helpImmunize
S
2

speechSynthesis.getVoices() will return an array of SpeechSynthesisVoice objects that can be used.


This list is made up of both local voices and voices that the browser will fetch from the server, and will therefore differ depending on the operating system and the browser. Each SpeechSynthesisVoice object has a Boolean 'localService' property which lets you know if it's supplies by the operating system or the browser.


To get more local voices, the user would need to download more voice packages from their operating system's control panel / settings.


On windows, for example, under the speech settings (not to be confused with the speech recognition app) there is a "manage voices" section where the user can select voice packages to download from a list of languages and dialects. One click and it downloads and installs. Each voice package would contain a few voices.



Note that once the speechSynthesis.getVoices() function has been called, the array will be populated with the voices available at the time of the function call. In order for the newly downloaded voices to be included in the array, the user would need to refresh the page in the browser, and possibly also close & reopen the browser and/or delete the cache.

Selfconfessed answered 6/10, 2021 at 14:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.