如何在web应用程序中合成语音?
有没有办法使用HTML5网络语音应用编程接口?
例如,如果我想要合成句子‘一只敏捷的棕色狐狸跳过懒狗’,我怎么能做到这一点,而不播放预先录制的某人准确地读到这句话的文件
发布于 2013-05-16 05:45:14
就目前而言,作为Web Speech API Specification一部分的SpeechSynthesis特性还没有在任何浏览器中实现。
不过,您可以看看this Chrome extension。
编辑:
似乎最新的Chrome Canary版本可能包含该功能,但是它只指定该功能已经启动(http://www.chromestatus.com/features),我无法找到任何有关它的更多实质性信息。
EDIT2:
正如@cdf在评论中提到的,似乎你现在可以通过启动带有--enable-speech-synthesis标志的chrome来使用这个功能了。请参阅this post。
EDIT3:
这似乎在Webkit中,但目前不在iOS中。即使是在iOS上的Chrome中也不是。演示 @BrandonAaskov
发布于 2015-08-09 14:22:39
这段代码可以在Chrome和Safari上运行(取自我的应用程序ttsreader):
if (!('speechSynthesis' in window)) {
// Synthesis not supported.
alert('Speech Synthesis is not supported by your browser. Switch to Chrome or Safari');
}
var msg = new SpeechSynthesisUtterance('hello world');
msg.volume = 1; // 0 to 1
msg.rate = 0.9; // 0.1 to 10
msg.pitch = 1; //0 to 2
msg.lang = "en-GB";
msg.text = "I will speak this out";
speechSynthesis.speak(msg);https://stackoverflow.com/questions/16575149
复制相似问题