Techumber
Home Blog Work

JavaScript Text To Speech

Published on April 30, 2019

Simple JavaScript speech synthesis.

const speak = (message: string) => {
  var msg = new SpeechSynthesisUtterance(message);
  var voices = window.speechSynthesis.getVoices();
  msg.voice = voices[0];
  window.speechSynthesis.speak(msg);
};

Example