HTML 语音无法在 Safari 上运行 mac "TypeError"
HTML speech not working on Safari mac "TypeError"
HTML5 语音无法在 mac 10.0.1,
的 Safari 上运行
我收到错误,
TypeError: Argument 1 ('utterance') to SpeechSynthesis.speak must be
an instance of SpeechSynthesisUtterance
它适用于 Chrome 和 Firefox,而且我很确定它曾经适用于 Safari...
var u = new SpeechSynthesisUtterance();
u.text = "hello world";
u.lang = "en";
window.speechSynthesis.speak(u);
好吧,终于想通了。
我有一些兼容代码来支持没有 html5 语音的浏览器,
if (SpeechSynthesisUtterance == undefined) {
function SpeechSynthesisUtterance(text) {
this.text = text;
}
}
这适用于 Chrome 和 Firefox,但在 Safari 上似乎在解析脚本时会评估任何脚本中的任何函数,因此即使 SpeechSynthesisUtterance 已经存在也会声明该函数。
我想我需要换一种方式...
HTML5 语音无法在 mac 10.0.1,
的 Safari 上运行我收到错误,
TypeError: Argument 1 ('utterance') to SpeechSynthesis.speak must be an instance of SpeechSynthesisUtterance
它适用于 Chrome 和 Firefox,而且我很确定它曾经适用于 Safari...
var u = new SpeechSynthesisUtterance();
u.text = "hello world";
u.lang = "en";
window.speechSynthesis.speak(u);
好吧,终于想通了。
我有一些兼容代码来支持没有 html5 语音的浏览器,
if (SpeechSynthesisUtterance == undefined) {
function SpeechSynthesisUtterance(text) {
this.text = text;
}
}
这适用于 Chrome 和 Firefox,但在 Safari 上似乎在解析脚本时会评估任何脚本中的任何函数,因此即使 SpeechSynthesisUtterance 已经存在也会声明该函数。
我想我需要换一种方式...