Now let’s write an elementary function that adds only final results to a text box ( as well as can be used): – the probability of the given word correct decoding (value from 0 to 1).– the Boolean value that shows whether this result is final or interim.The first element is a most probable recognized word.
event.results – the j-th alternative of a recognized word.event.resultIndex – the current recognition result index.Each array element corresponds to a recognized word on the i recognition stage. event.results – the array containing recognition result objects.The event object has the following fields: Recognition.onresult = function (event) Īdd the result handling logic inside this function. Now you need to initialize the recognition results handler: The following function is called to stop recognition: To start recognizing you need to call the function: By default, it corresponds to the browser language. The default value is false.ģ) Set the recognition language. The user will see a constantly refreshing text, otherwise, the recognized text will be available only after a pause. Thus you have access to interim recognition results and can display them in the text box immediately after receiving them. a speech pause will stop the recognition process).Ģ) Enable interim results fetching. By default this property is set to false (i.e. Var recognition = new webkitSpeechRecognition() įurther, you can set the following speech recognition parameters:ġ) Set the continuous recognizing that enables the user to make long pauses and dictate large texts. To start using API, you need to create a new object that will be employed for recognition: This method is based on the interaction with Web Speech API with the help of JavaScript ( demo). The Second Method – using Web Speech API on JavaScript The interim results are not displayed which contributes to poor feedback as the user sees the recognition result only after they stop talking and the recognition process is finished.When you resume speech recognition in the same box, the old value is substituted by a new one, so you can’t add data.Speech recognition is stopped after a pause.However, there’re significant disadvantages: The browser doesn’t request the user to allow to use the microphone.The x-webkit-speech attribute’s advantages are: But you can change it in two ways:ġ) By adding the attribute lang=”en” where the attribute value defines the language to be recognized: You only need to add the attribute x-webkit-speech:Īnd you get a text box that allows you to dictate a text.īy default, the recognition language will be the same as that set in your browser.
The easiest way to use this technology is to use the already implemented functionality for the html tag. Currently, developers have two options of implementing speech recognition on web-pages. Speech recognition supports several popular languages and is quite effective. Conversely, Web Speech API enables you to transform text into speech. Web Speech API is the JavaScript library that allows speech recognition and speech-to-text conversion. One of the newest and most interesting features introduced in this version was Web Speech API support. This February Google released Chrome version 25. Check our apps for Atlassian Products: Confluence, Jira, Bitbucket.