Skip to content

Instantly share code, notes, and snippets.

@alexspeller
Created February 16, 2023 16:40
Show Gist options
  • Save alexspeller/243d929f374357983b1674b926806a24 to your computer and use it in GitHub Desktop.
Save alexspeller/243d929f374357983b1674b926806a24 to your computer and use it in GitHub Desktop.
javascript:(function()%7Blet%20synth%20%3D%20window.speechSynthesis%3Blet%20voice%3Bfunction%20setVoice()%20%7Bvoice%20%3D%20synth.getVoices().find(v%20%3D%3E%20v.lang%20%3D%3D%3D%20%22pt-PT%22)%3Bif%20(voice)%20%7BactuallySpeak()%3B%7D%7D%3Bfunction%20handleError(event)%20%7Balert(%22There%20was%20an%20error%22)%3B%7Dfunction%20actuallySpeak()%20%7Blet%20text%20%3D%20document.querySelector(%22textarea%5Bname%3Dtext%5D%22).value%3Bif%20(text.trim()%20%3D%3D%3D%20%22%22)%20%7Breturn%3B%7Dconst%20utterThis%20%3D%20new%20SpeechSynthesisUtterance(text)%3ButterThis.voice%20%3D%20voice%3ButterThis.onerror%20%3D%20handleError%3B%2F*%20utterThis.pitch%20%3D%20pitch.value%3ButterThis.rate%20%3D%20rate.value%3B%20*%2Fsynth.speak(utterThis)%3B%7DsetVoice()%3Bif%20(speechSynthesis.onvoiceschanged%20%3D%3D%3D%20null)%20%7BspeechSynthesis.onvoiceschanged%20%3D%20setVoice%3B%7D%7D)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment