Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

js 离线的语音合成

请问一下离线版的文字转语音怎么搞,科大讯飞和百度的都要钱,想找免费的插件,我用下面这段代码在google里并没有起效果。。。。

    var utterThis = new window.SpeechSynthesisUtterance()
    utterThis.text = "测试测试测试测试";
    window.speechSynthesis.speak(utterThis)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
<!doctype html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport"
 content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title>Document</title>
</head>
<body>
<button onclick="speak();">Press to manually speak</button>
<script>
 function speak() {
    var utterThis = new window.SpeechSynthesisUtterance()
    utterThis.text = "测试测试测试测试";
 window.speechSynthesis.speak(utterThis)
  }
  speak();
</script>
</body>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...