web speech api - speech synthesis .lang property not working

ε祈祈猫儿з 提交于 2019-12-02 05:16:43

Seems like Chrome broke recently. I had code working, now its not.

https://code.google.com/p/chromium/issues/detail?id=582455

As a work-around, you can set the .voice

voices = window.speechSynthesis.getVoices()

var utterance = new SpeechSynthesisUtterance("lo que practico");

utterance.voice = voices[3];
utterance.lang = voices[3].lang;

window.speechSynthesis.speak(utterance);

Perhaps the API changed as before when a female/male voice were both available it was not possible to pick one in particular. I still set lang for other browsers (or older chromes).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!