执行语音合成

5年以前  |  阅读数:369 次  |  编程语言:JavaScript 

执行语音合成 (实验)。

使用SpeechSynthesisUtterance.voicewindow.speechSynthesis.getVoices()将邮件转换为语音。使用window.speechSynthesis.speak()播放该消息。了解有关Web 语音 API 的 SpeechSynthesisUtterance 接口的详细信息.

const speechSynthesis = message => {
const msg = new SpeechSynthesisUtterance(message);
msg.voice = window.speechSynthesis.getVoices()[0];
window.speechSynthesis.speak(msg);
};
// speechSynthesis('Hello, World') -> plays the message

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8