1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2025-10-16 15:38:44 +02:00
cheatsheets/js-speech.md
Rico Sta. Cruz 511de900ba
Formatting updates (#2133)
- Update some sheets which have very long sections
- Remove `layout: 2017/sheet` (everything has the same layout now)
- Remove outdated sheets
2024-04-03 18:30:24 +11:00

488 B

title, category, weight
title category weight
JavaScript speech synthesis JavaScript -1

SpeechSynthesisUtterance

{: .-one-column}

function speak (message) {
  var msg = new SpeechSynthesisUtterance(message)
  var voices = window.speechSynthesis.getVoices()
  msg.voice = voices[0]
  window.speechSynthesis.speak(msg)
}
speak('Hello, world')

See: SpeechSynthesisUtterance (developer.mozilla.org)