长话短说,语音合成的音量、速率和音高不起作用。有没有其他人有这个问题并且知道如何解决它,或者我一个人?
长话短说:
对我来说,语音合成的音量、速率和音高不起作用。这是我的语音功能:
function speak(message, voice, callback, volume, rate, pitch, start, lang) {
if (speech) {
window.speechSynthesis.onvoiceschanged = function() {
voices = window.speechSynthesis.getVoices();
var msg = new SpeechSynthesisUtterance();
msg.voice = (typeof voice != "undefined" && voice != 0) ? voices[voice] : voices[0]; // Note: some voices don't support altering params
msg.volume = (typeof volume != "undefined" && volume != 0) ? volume : 1; // 0 to 1
msg.rate = (typeof rate != "undefined" && rate != 0) ? rate : 1; // 0.1 to 10
msg.pitch = (typeof pitch != "undefined" && pitch != 0) ? pitch : 2; //0 to 2
msg.text = message;
msg.lang = (typeof lang != "undefined" && lang != 0) ? lang : "en-US";
msg.onstart = function(event) {
if (typeof start != "undefined" && start != 0) {
start(event);
}
}
msg.onend = function(event) {
console.log(event.elapsedTime);
if (typeof callback != "undefined" && callback != 0) {
callback(event);
}
};
speechSynthesis.speak(msg);
};
}
}
但是,当我调用speak("Hello", 0, 0, 0.1)
它时,它的输出与speak("Hello")
. 我想让它输出相同但更柔和的东西。
我目前正在关注http://updates.html5rocks.com/2014/01/Web-apps-that-talk---Introduction-to-the-Speech-Synthesis-API。