ctrlcv-dev.comgithub

JavaScript 语音合成cheatsheet

贡献者:BAI

SpeechSynthesisUtterance

实验属性,不兼容 IE 所有版本

JS
function speak(message) {
var msg = new SpeechSynthesisUtterance(message);
var voices = window.speechSynthesis.getVoices();
msg.voice = voices[0];
window.speechSynthesis.speak(msg);
}
JS
speak("Hello, world");

详见: SpeechSynthesisUtterance (developer.mozilla.org)