Skip to content

Instantly share code, notes, and snippets.

@frumpel
Created January 13, 2026 02:50
Show Gist options
  • Select an option

  • Save frumpel/08d31f583efa0f9e39d8f3cc56b943c5 to your computer and use it in GitHub Desktop.

Select an option

Save frumpel/08d31f583efa0f9e39d8f3cc56b943c5 to your computer and use it in GitHub Desktop.
Cycle through browser speechSynthesis voices

Running this in the browser console will cycle through all voices for language 'en*'.

(function() {
  play();

  async function play() {
    let all = "Do no blue next turn. \n \
               Do no blue next turn but add +2 if you score. \n Bye.";

    sentences = all.split('\n');
    voices = window.speechSynthesis.getVoices();

    for (j=0; j < voices.length; j++) {
      if (voices[j].lang.startsWith('en')) {
        console.log(voices[j])
        for (i = 0; i < sentences.length; i++) {
          await getNextAudio(voices[j],sentences[i]);
        }
      }
    }

    async function getNextAudio(voice,sentence) {
      console.log(sentence);
      let audio = new SpeechSynthesisUtterance(sentence);
      audio.voice = voice;
      window.speechSynthesis.speak(audio);

      return new Promise(resolve => {
        audio.onend = resolve;
      });
    } 
  }
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment