HTML5 speech is not working on Safari on a mac 10.0.1,
I get the error,
TypeError: Argument 1 ('utterance') to SpeechSynthesis.speak must be an instance of SpeechSynthesisUtterance
It works on Chrome and Firefox, and I'm pretty sure it used to work on Safari...
var u = new SpeechSynthesisUtterance();
u.text = "hello world";
u.lang = "en";
window.speechSynthesis.speak(u);
Okay, finally figured it out.
I had some compatibility code to support browser without html5 speech,
if (SpeechSynthesisUtterance == undefined) {
function SpeechSynthesisUtterance(text) {
this.text = text;
}
}
This works on Chrome and Firefox, but on Safari it seems that any function in any script is evaluated when the script is parsed, so the function get declared even though SpeechSynthesisUtterance already exists.
Guess I'll need to do this differently...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With