问题如下
- 通过 js 模拟点击,刷新页面后老是弹出 M71 禁令
- 怎样可以不手动触发也可以播放,(因为 chrome 已经禁用了 auto-play)
- 还有没有更好用的的 JavaScript 离线 TTS (开源不收费的)
- 目前已知开源的基本不支持中文
代码如下
var msg = new SpeechSynthesisUtterance(speakName);
msg.voice = speechSynthesis.getVoices().filter(
function (voice) {
return voice.name == 'Google 普通话(中国大陆)';
})[0];
speechSynthesis.speak(msg);
禁令如下
[Deprecation] speechSynthesis.speak() without user activation is no longer allowed since M71, around December 2018. See https://www.chromestatus.com/feature/5687444770914304 for more details
演示地址多次刷新不手动触发也会在 console 弹出
http://cr.kungfoo.net/speech/immediately-speak.html