<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body onload="myFunction()">
<script>
function myFunction() {
// Create the utterance object setting the chosen parameters
var utterance = new SpeechSynthesisUtterance();
var myarray = new Array(4);
myarray[0] = "Move Bay from door 10 to 20";
utterance.text = myarray[0];
utterance.lang = "ar-uk";
speechSynthesis.speak(utterance);
}
</script>
</body>
</html>
将文本传递给语音合成属性文本并尝试将文本转换为语音
最佳答案
看这里:SpeechSynthesisUtterance Docs
IE不支持。
关于javascript - 下面的代码适用于 chrome,但同样的代码不适用于 Internet Explorer。如何在 Internet Explorer 中使用语音合成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47550659/