I'm writing a javascript code which I want to welcome users when they click the "start button". It's working, in english, but the point is that I want it to say things in Brazilian Portuguese (pt-BR). I tried a lot of solutions, but seems it will not work. Can anyone please help me?
The code is:
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<script>
startTalking = function(line){
var text = new SpeechSynthesisUtterance();
text.lang = "pt-BR";
text.text = line;
speechSynthesis.speak(text);
}
</script>
</head>
<body>
<button id="startButton" onclick = "startTalking("Bem vindo!")"></button>
</body>
</html>
When I click the button the script works, but the text received in the parameter is spoken by a voice in English (USA).
Does anyone has any clue on how to fix it?
Thanks!!