Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 507 Bytes

js-speech.md

File metadata and controls

24 lines (20 loc) · 507 Bytes
title category layout weight
JavaScript speech synthesis
JavaScript
2017/sheet
-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)