【问题标题】:Synthesize speech from text in web app从 Web 应用程序中的文本合成语音
【发布时间】:2013-05-15 21:18:32
【问题描述】:

如何在网络应用中合成语音?

有没有办法使用 HTML5 Web Speech API?

例如,如果我想合成句子“一只快速的棕色狐狸跳过懒狗”,如果不播放预先录制的某人正在阅读该句子的文件,我怎么能做到这一点

【问题讨论】:

标签: javascript html text-to-speech voice speech


【解决方案1】:

就目前而言,Web Speech API Specification 中的SpeechSynthesis 功能尚未在任何浏览器中实现。

不过,你可以看看this Chrome extension

编辑:

似乎最新的 Chrome Canary 版本可能包含该功能,但它仅指定该功能已启动 (http://www.chromestatus.com/features),我无法找到有关它的更多实质性信息。

EDIT2:

正如@cdf 在 cmets 中提到的,您现在似乎可以通过启动带有 --enable-speech-synthesis 标志的 chrome 来使用该功能。请参阅this post

EDIT3:

这似乎现在在 Webkit 中,但目前不在 iOS 上。甚至在 iOS 上的 Chrome 中也没有。 演示 @BrandonAaskov

【讨论】:

【解决方案2】:

该代码适用于 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);

【讨论】:

    猜你喜欢
    • 2014-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-26
    相关资源
    最近更新 更多