Please note that the speechSynthesis API is not yet supported on all browsers.
The code below help you check for browser support:
if('speechSynthesis'inwindow){alert("Broswer supports speech synthesis š");}else{alert("Sorry, your browser doesn't support the speech synthesis API !");}
Check out MDN's speak easy synthesis demo which works on Chrome. There's two things you need to do to set it up properly:
1) As is the case with the Web Audio API generally, Chromium Browsers will not allow audio to be played without the user interacting with the page first. You need to put the speech synthesis code behind an event listener for some page event like a button click.
2) It seems that Chrome, unlike FireFox, does not have access to system voices when speechSynthesis is initialised for the first time. You need to add an event listener which refers to a function when the voices are found, something like - speechSynthesis.onvoiceschanged = getVoices. The technology is still experimental so I expect this will change in the future.
Unfortunately it didn't work for me
Hi Josias,
Please note that the speechSynthesis API is not yet supported on all browsers.
The code below help you check for browser support:
I use Chrome and it's says my browser supports it
Check out MDN's speak easy synthesis demo which works on Chrome. There's two things you need to do to set it up properly:
1) As is the case with the Web Audio API generally, Chromium Browsers will not allow audio to be played without the user interacting with the page first. You need to put the speech synthesis code behind an event listener for some page event like a button click.
2) It seems that Chrome, unlike FireFox, does not have access to system voices when
speechSynthesis
is initialised for the first time. You need to add an event listener which refers to a function when the voices are found, something like -speechSynthesis.onvoiceschanged = getVoices
. The technology is still experimental so I expect this will change in the future.codepen.io/richardengle/pen/KKNzKXg is my version of this, combined with some hacks. try it :]
Link down! No archive available
This is old but see my comment. You need to wait for voices to load.