Skip to content

Instantly share code, notes, and snippets.

@danharper
Last active October 7, 2016 16:45
Show Gist options
  • Select an option

  • Save danharper/3d6941322bf6d33a1dc716775a7ea46b to your computer and use it in GitHub Desktop.

Select an option

Save danharper/3d6941322bf6d33a1dc716775a7ea46b to your computer and use it in GitHub Desktop.

Revisions

  1. danharper revised this gist Oct 7, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions voices.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    // would've been awesome if `speechSynthesis.speak` returned a promise which resolves on finish.. :(

    const sleep = ms => new Promise(r => setTimeout(r, ms))

    async function go(msg) {
  2. danharper created this gist Oct 7, 2016.
    10 changes: 10 additions & 0 deletions voices.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    const sleep = ms => new Promise(r => setTimeout(r, ms))

    async function go(msg) {
    for (let v of speechSynthesis.getVoices()) {
    speechSynthesis.speak(u = new SpeechSynthesisUtterance(msg), u.voice = v, u)
    await sleep(1000)
    }
    }

    go('Hello World')