For window.speechSynthesis.speak()
to render audio output at Chromium browser the user needs to have speech-dispatcher
installed and launch the browser with --enable-speech-dispatcher
flag.
onvoiceschanged
event handler and window.speech.synthesis.getVoices()
needs to be called to populate the list of available voices. The API is not straightforward; .getVoices()
may need to be called twice for the SpeechSynthesisVoice
objects to populate the array returned by .getVoices()
.
Note that there is a potential for the calls to .speak()
to be placed in a queue and not be rendered as audio output, which is not immediately evident; calling window.speechSynthesis.cancel()
clears the queue, where the audio output could then be rendered unexpectedly.
You can then use window.speechSynthesis.speak()
.
Have been trying for some time now to get SSML parsing enabled by default at Chromium browser for *nix; without using an external web service which requires either some form of EUA or is not free as in beer.
The list of entities that have contacted and questions asked to achieve this is quite lengthy, for example
Firefox at *nix also does not parse SSML.
Perhaps with more interest by users at large we can finally get this feature enabled by default.
Though there are workarounds for SSML parsing without using an external web service; this first link below is still unanswered; though includes PHP code that calls the binary using shell_exec()
following $_POST
to a local server
Note, that there are several bug with the current Web Speech API implementation, notably that changing volume
property at SpeechSynthesisUtterance
has no effect on audio output at both Chromium and Firefox
There is also a bug when using .pause()
and .resume()
, which encountered when trying to programmatically parse <break>
element of SSML
An alternative to using the apparently dead Web Speech API is speak.js
which was created by porting espeak
to JavaScript or meSpeak.js
, which is a fork of speak.js
. espeak-ng
is now actively maintained, for example using a modified version of meSpeak.js
or using online dictionaries which serve voice files reflecting the word
Interestingly, after posting that Answer the "gstatic" "dictionary" no longer served the audio files.
Fortunately, we have
This is a web, Android and iOS app for collecting speech donations for
the Common Voice project.
which is quite active.
We can also use Native Message at both Chromium/Chrome and Firefox to call interact with the native shell and call the binary itself
this code achieves expected result with minimal modification using Native Messaging
or as a drastic measure, change the binary
(opinion, supported by facts follow)
There is a substantial web service market for speech synthesis technologies, both in the generation thereof ( "[L]yrebird") and the recognition of - for profit i.e.g., "*lexa"; "*olly"; (*bm) "*atson *luemix"; (*oogle) "*ctions"; etc.
It is up to open source developers to continue efforts directed towards maintaining open source (FOSS; FLOSS) speech synthesis technologies at open source browsers. If we want these technologies to be implemented in browsers by default, open source developers have to compose the code to make that happen.
window.speechSynthesis.getVoices()
andonvoiceschanged
event usage cannot be ignored for interop. – Squander