I have SpeechSynthesisUtterance working in my native language (English) but I need to set the language to Italian for correct pronunciation.
The code works correctly in Mac Safari but in iOS Safari the pronunciation is English not Italian.
An easy test is the Italian: "Ho i soldi", "h"is silent in Italian.
<!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>
Here is a test example of the above code.
I have downloaded Italian "Luca" and have set it as the Default at Settings:General:Accessibility:Speech:Voices:Italian;Luca
Note:
I have posted an inquiry to the Apple Safari and Web Development Forum on Jul 26, 2018 with the result of no response to date: (422 Views, 0 Replies).
I have also submitted an Apple Developer Technical Support (DTS) request August 16, 2018 that was declined with a suggestion to post to the Web Development Forum.
This while this might be deemed off-topic please consider I have tried debugging and requested help from Apple which has been ignored and denied.
Udate:
Thus seems to be an iOS beta issue, even the Chrome and Firefox apps has the English pronunciation. I have files a Beta bug report on this issue.
msg.voice = speechSynthesis.getVoices().filter(function(voice) { return voice.name == 'Luca'; })[0];
– UnluckySpeechSynthesis.getVoices().filter(function(voice){return voice.name == 'luca';})
returns what you expect on the devices that don't seem to be working? (e.g. by writing it to the page, or putting it in analert()
call.) – TriboluminescentSpeechSynthesisUtterance
JavaScript
class. – Eddra