---
title: "Discussion on \"Text to Speech Using the Web Speech API in JavaScript\" | Hashnode"
description: "Discussion on \"Text to Speech Using the Web Speech API in JavaScript\". The Web Speech API is used to incorporate voice data into web apps. In this tutorial, we will build a simple webpage that uses the Web Speech API to implement text to speech. You can check the browser compatibility for the Web Speech API here.\nPrereq..."
url: "https://hashnode.com/posts/text-to-speech-using-the-web-speech-api-in-javascript/60051eea848f4c3b9a0f0d7a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Text to Speech Using the Web Speech API in JavaScript](https://blog.zolomohan.com/text-to-speech-using-the-web-speech-api-in-javascript?utm_source=hashnode&utm_medium=feed)

The Web Speech API is used to incorporate voice data into web apps. In this tutorial, we will build a simple webpage that uses the Web Speech API to implement text to speech. You can check the browser compatibility for the Web Speech API here. Prereq...

Jan 18, 2021 · 9 min read · blog.zolomohan.com  
Updated Feb 22, 2022  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Mohan Raj](https://hashnode.com/@zolomohan)

@zolomohan · Chennai, India

  
[View profile](https://hashnode.com/@zolomohan)

MERN | React Native | Blockchain | Web3

Helping other developers avoid some of the same challenges I faced.

## Responses 4

Markdown supported · ⌘↵ to post

[Sameer Malik](https://hashnode.com/@sameer2malik)

[Sep 1, 2022](https://hashnode.com/posts/text-to-speech-using-the-web-speech-api-in-javascript/60051eea848f4c3b9a0f0d7a/comment/6310d2e556df9e8e5025ccf5)

you are doing amazing work, I like your script , please give me tips to add this script to my blog post

[Bijender Singh](https://hashnode.com/@ben003)

[Jan 10, 2022](https://hashnode.com/posts/text-to-speech-using-the-web-speech-api-in-javascript/60051eea848f4c3b9a0f0d7a/comment/61dc39ddcda0d0294b69b55c)

It's not working on Safari. It gives zero voices. And then take English as a default. Anyone help me in the situation.

[Pepinho doSamba](https://hashnode.com/@Pepinho)

[Feb 19, 2021](https://hashnode.com/posts/text-to-speech-using-the-web-speech-api-in-javascript/60051eea848f4c3b9a0f0d7a/comment/602f1a04bfecab23c3524ffc)

Hi, Mohan. I just implemented your fantastic code in my website. It is working flawlessly but sometimes it just goes silent but the speech engine never produces an error message. What do you think I should do in this case?

Thank you for sharing your expertise!

[Mohan Raj](https://hashnode.com/@zolomohan)

[Feb 19, 2021](https://hashnode.com/posts/text-to-speech-using-the-web-speech-api-in-javascript/60051eea848f4c3b9a0f0d7a/comment/602f1a04bfecab23c3524ffc#reply-602f53301591c5239ebdc3dc)

Hi [Pepinho doSamba](https://hashnode.com/@Pepinho).

Please go through this MDN Doc to handle errors.

[developer.mozilla.org/en-US/docs/Web/API/SpeechSy…](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisErrorEvent/error)

[Bhargav Ponnapalli](https://hashnode.com/@codewithbhargav)

[Jan 18, 2021](https://hashnode.com/posts/text-to-speech-using-the-web-speech-api-in-javascript/60051eea848f4c3b9a0f0d7a/comment/600522b6848f4c3b9a0f0dba)

This is fantastic. Super helpful. I will probably build a React hook around TextToSpeech sometime based on your code snippet.

Thanks Mohan Raj!

[Mohan Raj](https://hashnode.com/@zolomohan)

[Jan 18, 2021](https://hashnode.com/posts/text-to-speech-using-the-web-speech-api-in-javascript/60051eea848f4c3b9a0f0d7a/comment/600522b6848f4c3b9a0f0dba#reply-60053c98848f4c3b9a0f0f98)

That's a great idea!
