Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a voice / language to speechSynthesis?

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

like image 881
Merlin -they-them- Avatar asked Nov 19 '17 17:11

Merlin -they-them-


People also ask

How do I add text-to-speech in HTML?

Open the HTML in your browser and enter some text in the input. You can ignore the <select> box at this point, we'll use that in the next section. Hit "Say it" and listen to the browser read out your words. It's not much code to get the browser to say something, but what if we want to pick the voice that it uses.

What is Speech Synthesis API?

The SpeechSynthesis interface of the Web Speech API is the controller interface for the speech service; this can be used to retrieve information about the synthesis voices available on the device, start and pause speech, and other commands besides. EventTarget SpeechSynthesis.

How do I change the voice in SpeechSynthesisUtterance?

To use a voice, set the voice property on your SpeechSynthesisUtterance instance to the desired SpeechSynthesisVoice object. The example below shows how to do this. var utterance = new SpeechSynthesisUtterance('Hello Treehouse'); var voices = window. speechSynthesis.

How does voice synthesis work?

A speech synthesizer is a computerized voice that turns a written text into a speech. It is an output where a computer reads out the word loud in a simulated voice; it is often called text-to-speech. It is not only to have machines talk simply but also to make a sound like humans of different ages and gender.


1 Answers

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.

like image 157
Naftoli Ost Avatar answered Oct 20 '22 00:10

Naftoli Ost