Converting from
Text to Speech

Jorge Baumann

with Javascript

Speech API ๐Ÿค”

The web speech API converts text to spoken words.

You can even select a voice

How can we make this browser talk?

Jorge Baumann


 const synth = window.speechSynthesis

 const text = 'Baumann is cool'

 const utterThis = 
        new SpeechSynthesisUtterance(text)

 synth.speak(utterThis)

The last thing we have to do is let the synthesizer say our words.

Now we can create a new speech synthesis utterance

๐Ÿ”Š

Jorge Baumann

Sounds boring?

Ok, let's change it and make it funny!


  const synth = window.speechSynthesis

  // Select voice
  const voice = this.voices.find(v => v.name === 'Jorge')

  // Next we create a new speech synthesis utterance
  const utterThis = new SpeechSynthesisUtterance(this.text)

  // Set voice
  utterThis.voice = voice
  
  // Default tone is 1
  utterThis.pitch = 1.5

  // Default speed is 1
  utterThis.rate = 1.8

  // Speak!
  synth.speak(utterThis)

๐Ÿ”Š

Jorge Baumann

๐Ÿฆ„ Jorge Baumann ๐Ÿฆ„

Made with Slides.com