VOOZH about

URL: https://www.geeksforgeeks.org/javascript/how-to-convert-speech-into-text-using-javascript/

⇱ How to convert speech into text using JavaScript ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to convert speech into text using JavaScript ?

Last Updated : 5 Jan, 2021

In this article, we will learn to convert speech into text using HTML and JavaScript. 

Approach: We added a content editable "div" by which we make any HTML element editable.

We use the SpeechRecognition object to convert the speech into text and then display the text on the screen.

We also added WebKit Speech Recognition to perform speech recognition in Google chrome and Apple safari.

InterimResults results should be returned true and the default value of this is false. So set interimResults= true

Use appendChild() method to append a node as the last child of a node.

Add eventListener, in this event listener, map() method is used to create a new array with the results of calling a function for every array element. 

Note: This method does not change the original array. 

Use join() method to return array as a string.

Final Code:

Output: 

If the user tells "Hello World" after running the file, it shows the following on the screen.

Hello World
Comment