gpt4 book ai didi

javascript - 网络语音 API - 语音合成 .lang 属性不起作用

转载 作者:行者123 更新时间:2023-11-30 16:18:39 26 4
gpt4 key购买 nike

我正在尝试使用网络语音 API 来转录葡萄牙语中的单词,我将属性设置为“pt-BR”(不幸的是葡萄牙语 - 不支持欧洲语)但是,总是用英语回复。

有人可以帮忙吗?

谢谢

代码:

        <script type="text/javascript"> 
var synth = window.speechSynthesis;
function falatarea(){
var utteranceY = new SpeechSynthesisUtterance();
utteranceY.text = "teste";
utteranceY.lang = "pt-BR";
utteranceY.voice = "pt-BR";
window.speechSynthesis.speak(utteranceY);
}
</script>

最佳答案

Chrome 好像最近坏了。我的代码可以正常工作,但现在不行了。

https://code.google.com/p/chromium/issues/detail?id=582455

作为解决方法,您可以设置 .voice

voices = window.speechSynthesis.getVoices()

var utterance = new SpeechSynthesisUtterance("lo que practico");

utterance.voice = voices[3];
utterance.lang = voices[3].lang;

window.speechSynthesis.speak(utterance);

也许 API 像以前一样发生了变化,当女性/男性声音都可用时,无法特别选择一个。我仍然为其他浏览器(或旧版 chrome)设置 lang。

关于javascript - 网络语音 API - 语音合成 .lang 属性不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35091595/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com