DEV Community

Cover image for Javascript text-to-sppech
Alison Silva 🔥💯⛏️
Alison Silva 🔥💯⛏️

Posted on

1 1

Javascript text-to-sppech

Did you know javascript have native text-to-sppech?
Try it in your console.

const speak = (msg, lg = 'en') => {
  const sp = new SpeechSynthesisUtterance(msg);
  [sp.voice] = speechSynthesis.getVoices();
  sp.lang = lg;
  speechSynthesis.speak(sp);
};

speak('Hello, my name is Alison Silva, and I\'m a software developer. Did you know javascript have native text-to-sppech?');
Enter fullscreen mode Exit fullscreen mode

You include can change the language as you see in the code above.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more