语音在FireFox中首次发声后便停止工作,但在Chrome中工作 [英] SpeechSynthesis stops working after first utterance in FireFox, but works in Chrome

查看:55
本文介绍了语音在FireFox中首次发声后便停止工作,但在Chrome中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题非常简单,请参见 JSfiddle .

The problem is very simple, see JSfiddle.

SpeechSynthesis在Chrome中可以正常运行,但是在FireFox中首次发出语音后会神秘地停止.(在Safari中也对我有用.)欢迎提出任何想法,因为我没有太多经验.

SpeechSynthesis works fine in Chrome, but mysteriously stops after the first utterance in FireFox. (Works for me in Safari as well.) Any ideas welcome, as I don't have much to go by.

代码:

var u = new SpeechSynthesisUtterance();
var synth = window.speechSynthesis;
u.text = "hello";
synth.speak(u);
synth.speak(u);
synth.speak(u);

推荐答案

这实际上是 Firefox中的已知错误.

规范草案仍然不太清楚话语的可重用性,但是您可以在w3c上看到此问题github,他们同意应有的事实.

The specs drafts are still not very clear about the re-usability of an utterance, but you can see this issue on w3c's github, where they agreed on the fact it should be.

目前,一种解决方法是每次创建新的语音提示...

For the time being, one workaround is to create a new utterance every time...

var synth = window.speechSynthesis;

synth.speak(new SpeechSynthesisUtterance('hello'));
synth.speak(new SpeechSynthesisUtterance('hello'));
synth.speak(new SpeechSynthesisUtterance('hello'));

这篇关于语音在FireFox中首次发声后便停止工作,但在Chrome中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆