在 Web Speech API Specification 上给出的示例
speechSynthesis.speak(SpeechSynthesisUtterance('Hello World'));
在 chrome 上出现以下错误:
Uncaught TypeError: DOM object constructor cannot be called as a function.
有人可以帮忙吗?
谢谢!
最佳答案
我认为规范中有一个类型,您应该将 new
关键字与 SpeechSynthesisUtterance
对象一起使用。试试这个:
speechSynthesis.speak(new SpeechSynthesisUtterance('Hello World'));
关于javascript - speechSynthesis API 示例给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18292625/