

For example a user runs this speech to text program on its browser and presses the speech button and start speaking as “”, as user stops speaking the speech recognition program will stop and will display the transcript on the browser as “”. Then these words are returned as a transcript of a sentence on the user browser screen. When the user has stopped speaking the sentence, the result is stored in the form of an array of words. When the “runSpeechRecog()” function is triggered the webkitSpeechRecognition() is initialized and all the properties of this are stored in the reference and shows the below output as the browser is ready to listen to the user's spoken words. Var action = document.getElementById('action') Var output = document.getElementById('output') Step 7 − Use the recognition.start() method to start the speech recognition.ĭocument.getElementById("output").innerHTML = "Loading text." Step 6 − Now use recognition.onresult() to display the spoken words on the screen. Step 5 − Use “recognition.onstart()“, this function will return the action when the recognition is started. Let recognization = new webkitSpeechRecognition()

So that all the methods of webkitSpeechRecognition() class will be in the reference variable. Step 4 − Create an object of a webkitSpeechRecognition() constructor and store it in a reference variable. Step 3 − Select the “p” tag of HTML using Document Object Model (DOM) as document.getElementById(). Step 2 − Create a runSpeechRecog() arrow function inside a script tag as we are using internal javascript. Also create a tag with id “action” in it. Add an onclick event in it with the function name “runSpeechRecog()”. Step 1 − Create a HTML page as given below, create a HTML button using tag. We can also use SpeechRecognition() instead of webkitSpeechRecognition() as webkitSpeechRecognition() is used in chrome and apple safari browser for speech recognition. The basic syntax used in is − let recognization = new webkitSpeechRecognition() The spoken words are stored in it in an array which are then displayed inside the HTML element on the browser screen. The SpeechRecognition component recognizes the spoken words in the form of audio and converts them to the text. To convert the spoken words to the text we generally use the Web Speech API’s component that is “SpeechRecognition”.
