文本到语音在Firefox中有效,但在edge中无效

时间:2019-01-28 12:00:17

标签: text-to-speech

我在Firefox中运行了以下代码,但没有出现问题,但是边缘没有出现任何声音。它看起来与其他人在此处显示的代码非常相似。

var synth = window.speechSynthesis;

var voices = [];
voices = synth.getVoices();

var to_be_spoken = " ";
var the_speech_1 = " ";      //populated elsewhere

function mySpeech(){

to_be_spoken = the_speech_1

var to_speak = new SpeechSynthesisUtterance(to_be_spoken);

    to_speak.voice = voices[1]; // 0 is male, 1 is female
    to_speak.volume = 1;

window.speechSynthesis.speak(to_speak);

}

我看过Windows博客(blogs.windows.com/msedgedev/2016/06/01/introducing-speech-synthesis-api),位于“试驾”上的语音合成演示。在Edge中效果很好。

关于为什么我的代码无法在Edge中运行的任何建议都值得赞赏。

0 个答案:

没有答案