Changing the default speech synthases voice?


#1

I have an idea for an app, and it will require text to speech. However, i need to change the default voice to a different voice. How would i go about changing the voice being used for speech synthases? Also, would anyone know where i could get the “Australian Karen” voice engine to use with the app?

Thanks in advance!


#2

I feel like the chrome.ttsengine API is what you’re looking for, but I have no experience with this realm.


#3
Uncaught ReferenceError: chrome is not defined

Off to a great start :joy:


#4

Electron is built on part of Chromium, so there’s a good chance that ttsengine is in thee somewhere. If not, searching for “electron tts” turns up this Electron-specific package.


#5

The easiest way is probably to use the experimental Web Speech API.

Good information can be found on the page: Web apps that talk - Introduction to the Speech Synthesis API.

Here is a snippet which works out of the box on Mac OS X Yosemite 10.10.5 in my application based on Electron 1.7.6:

let synth = window.speechSynthesis;
let message = new SpeechSynthesisUtterance ();
let voices = synth.getVoices ();
for (let voice of voices)
{
	if ((voice.lang === 'en-AU') && (voice.name === 'Karen'))
	{
		message.voice = voice;
	}
}
// message.lang = 'en';
message.text = "Hello, Electron!";
speechSynthesis.speak (message);

HTH…