larryaronson.com

JavaScript SpeechSynthesis API

https://wicg.github.io/speech-api/
https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API

Three steps to TTS:

1. Create an utterance object

  utterance = new SpeechSynthesisUtterance();

2. Set the properties of the utterance object

  utterance.text = 'Hello World';
  utterance.rate = 1.2;

3. Speak the utterance

  speechSynthesis.speak(utterance);

A one-line expression:

  <h4 title="click to hear" onclick="speechSynthesis.speak(
  new SpeechSynthesisUtterance(this.innerHTML));">Hello World</h4>

Hello World

Adding Voice to WordPress
Presented to VoiceLunch/US, March 25, 2022

<    >