1

My native language is spanish, so my laptop is set in spanish....

the problem is that Im using my local server (localhost) to learn german and Ive set up some javacript code to speak out loud some words in german

         var msg = new SpeechSynthesisUtterance("der Hund");
        msg.lang = 'de-DE';
        msg.rate = 0.6;
        window.speechSynthesis.speak(msg);

It works pretty well (when online It speak out loud in german with german accent as set in the code)...until I go offline (without internet)...once that happens...the voice speaks out loud the same word as well der Hund but now with spanish accent...

So I would like to know...what should I do to make the API work correctly online and offline.

Martin
  • 22,212
  • 11
  • 70
  • 132
max
  • 105
  • 7
  • Please add which languages this is coded in? The code sample you show is more than just HTML. Thank you – Martin Jan 22 '20 at 00:24
  • Did you write this code from scratch or did you use a base javascript library to speak the language? – Martin Jan 22 '20 at 00:25
  • Have you set your HTML page to be ``? – Martin Jan 22 '20 at 00:26
  • @Martin good observation......I have this only tag `` is that correct? or do I need to ad to the html tag as well? – max Jan 22 '20 at 00:28
  • In HTML5 the `lang` tag in the `` element should be set. – Martin Jan 22 '20 at 00:29
  • [read this](https://www.w3.org/International/questions/qa-html-language-declarations.es) `;-)` – Martin Jan 22 '20 at 00:30
  • @Martin it make sense, but still not working :/ – max Jan 22 '20 at 00:35
  • Ok then the issue is your Javascript -- as asked above; what javascript library do you use to speak the language? – Martin Jan 22 '20 at 00:36
  • the API. `SpeechSynthesisUtterance()` – max Jan 22 '20 at 00:37
  • Also, according to [this example](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance/lang) you should be setting a `synth.getVoices` value as well, but I don't see that in your code.... – Martin Jan 22 '20 at 00:42
  • I commented `/msg.lang = 'de-DE';` with `` and not working – max Jan 22 '20 at 00:46
  • I suspect you have to set the `accent` in the `synth.getVoices` object.....? – Martin Jan 22 '20 at 00:46
  • I dont actually understand how touse that function – max Jan 22 '20 at 00:50
  • [Read this](https://stackoverflow.com/questions/42694586/how-to-change-voice-in-speech-synthesis) or otherwise find an online tutorial and / or guide as to how to use this technology. – Martin Jan 22 '20 at 00:52
  • good link thanks. Im supossed to use `msg.voice = "Google Deutsch";` but the script stops working...I think that here is the answer https://codepen.io/matt-west/pen/wGzuJ – max Jan 22 '20 at 00:58
  • Good luck with it – Martin Jan 22 '20 at 00:59
  • Ok I added the line `var voices = window.speechSynthesis.getVoices(); msg.voice = voices[6];` it selects the german voice...works online but not offline....such a frustration – max Jan 22 '20 at 01:08
  • 1
    What os are you on? Do you have a voice on your system in this language? If not, you need to install one, at the OS level. – Kaiido Jan 22 '20 at 01:37
  • @Kaiido I have windows 8. How should I install this german voice? – max Jan 22 '20 at 16:17
  • I guess [this](https://support.office.com/en-us/article/download-voices-for-immersive-reader-read-mode-and-read-aloud-4c83a8d8-7486-42f7-8e46-2b0fdf753130) is what you want, though I don't have a windows 8 at hand to try. And [for win10](https://support.office.com/en-us/article/how-to-download-text-to-speech-languages-for-windows-10-d5a6b612-b3ae-423f-afa5-4f6caf1ec5d3) – Kaiido Jan 23 '20 at 02:51

0 Answers0