leaonline / easy-speech

🔊 Cross browser Speech Synthesis also known as Text to speech or TTS; no dependencies; uses Web Speech API
https://leaonline.github.io/easy-speech/
170 stars 20 forks source link

Microsoft voices only loading on browser refresh in Chrome on Windows #255

Open RandyLoeb opened 5 months ago

RandyLoeb commented 5 months ago

[X] I have read the FAQ section and have checked that none of it describe the issue I'm about to report.

Describe the bug A clear and concise description of what the bug is.

On the initial load of the page in latest Chrome on Windows 10 (not mobile), all the google voices available load, but not the 3 microsoft voices. But if users refresh the page, the 3 microsoft voices appear.

Additional context [Add any other context about the problem here]

(https://longislandcw.github.io/morsebrowser/easysp23/). Click/expand More Settings accordion-> check expert settings, check voice, and then see the list in "choose speaker..." (note that all non-english google voices are hidden from the user).

Brave and Edge seem ok, ie the microsoft voices load without need to refresh.

RandyLoeb commented 5 months ago

also this is how I use the library:

EasySpeech.init({ maxTimeout: 10000, interval: 250 }).then((e) => {
      this.logToFlaggedWords(`easyspeechinit: ${e}`)
      this.populateVoiceList()
    }).catch((e) => {
      this.logToFlaggedWords(`error in easyspeechinit: ${e}`)
    })
RandyLoeb commented 5 months ago

well, a little workaround, the workflow for the page allows us to wait to call init until something is pressed. I am not sure if it is time, or the fact that user has clicked on something that enables the microsoft voices to be available.

jankapunkt commented 4 months ago

@RandyLoeb sorry I missed this one in the last month. So here is the issue: all voices should have been loaded when init is complete as the underlying event voiceschanged is usually the only source of "truth" we can get.

One thing to try though, would be to see, if voiceschanged fired multiple times in your specific case:

The code would be fairly easy to check:

const synth = window.speechSynthesis;

synth.addEventListener("voiceschanged", () => {
  // log output of synth.getVoices()
});

synth.getVoices() // sometimes required to initially trigger the voice list to update