zap*_*aph 6 html javascript safari mobile-safari
我有使用我的母语(英语)工作的SpeechSynthesisUtterance,但我需要将语言设置为意大利语以获得正确的发音.
该代码在Mac Safari中正常工作,但在iOS Safari中,发音是英语而非意大利语.
一个简单的测试是意大利语:"Ho i soldi","h"在意大利语中保持沉默.
<!DOCTYPE html><html lang='en' class=''>
<head><meta charset='UTF-8'></head>
<body>
<button id="Ho una prenotazione." onclick=speak(id)>Ho una prenotazione.</button>
I have a reservation
<script >
function speak(text) {
var msg = new SpeechSynthesisUtterance(text);
msg.lang = 'it-IT';
window.speechSynthesis.speak(msg);
}
</script>
</body></html>
Run Code Online (Sandbox Code Playgroud)
以下是上述代码的测试示例.
我已经下载了意大利语"Luca"并将其设置为默认设置:常规:可访问性:语音:语音:意大利语; Luca
我于2018年7月26日向Apple Safari和Web开发论坛发布了一个查询,结果是对日期没有回复:(422次,0篇回复).
我还提交了2018年8月16日的Apple开发人员技术支持(DTS)请求,该请求被拒绝,并建议发布到Web开发论坛.
虽然这可能被视为偏离主题,但请考虑我已尝试调试并请求Apple提供的帮助,但这些帮助已被忽略并被拒绝.
因此,似乎是iOS测试版问题,即使Chrome和Firefox应用程序都有英文发音.我有关于此问题的Beta bug报告.
小智 6
我遇到了这个问题(iOS 14.3)。
在 iOS 中,仅设置 lang 属性是不够的。您还需要设置语音属性。
例子:
const utterance = new SpeechSynthesisUtterance('156')
const lang = 'zh-CN'
// Without the following line, voice remains in English on iOS
// voicesList is here the retured value of speechSynthesis.getVoices()
utterance.voice = voicesList.find((voice) => voice.lang === 'zh-CN')
utterance.lang = 'zh-CN'
speechSynthesis.speak(utterance)Run Code Online (Sandbox Code Playgroud)
我必须在评论中发布这个小代表,所以我会将其作为答案发布.我看到你正在运行iphone 6s,但是我在我的iphone X和我的Mac上用不同的浏览器中的英语和意大利语试了一下.
您的手机或操作系统中可能存在问题,因为它似乎在我的设备上运行良好,您是否尝试过除了iPhone 6s以外的任何其他设备?