Tuesday, March 22, 2016

How to Add Speech Recognition to my web site





Open the Google web site on your microcomputer and you’ll realize alittle electro-acoustic transducer icon embedded within the search box. Click the icon, say one thing and your voice is quickly transcribed into words. in contrast to earlier speech recognition product, you not ought to train the browser to know your speech and, for people who don’t apprehend typewriting, speech is usually a quicker mode of input than the keyboard.

Sounds like magic, right? Well, did you recognize that you simply may also embody similar speech recognition capabilities to your own web site with many lines of code. guests will search your web site, or maybe fill forms, victimisation simply their voice. each Google Chrome and Firefox browsers support the speech recognition API.

Before we tend to dive into the particular implementation, let’s play with a operating demo. If you're viewing this page within Google Chrome (desktop or mobile), click the voice icon within the search box and say a pursuit question. you will have enable the browser to access your electro-acoustic transducer. after you square measure done speaking, the search results page can open mechanically.

Add Voice Recognition to your web site

The HTML5 net Speech API has been around for few years currently however it takes slightly a lot of work currently to incorporate it in your web site.

Earlier, you may add the attribute x-webkit-speech to any type input field and it'd become voice capable. The x-webkit-speech attribute has but been deprecated and you're currently needed to use the JavaScript API to incorporate speech recognition. Here’s the updated code:
We have the CSS to position the electro-acoustic transducer image within the input box, the shape code containing the input button and also the JavaScript that will all the serious work.

When the user click the mic image within the search box, the JavaScript checks if the user’s browser supports speech recognition. If so, it waits for the transcribed text to arrive from Google servers and so submits the shape.

The Dictation App conjointly uses the speech recognition API although it writes the transcribed text to textarea field rather than AN input box.

Some notes:

If the hypertext mark-up language type / search box is embedded within AN HTTPS web site, the browser won't repeatedly fire permission to use the electro-acoustic transducer.
You can modification the worth of the popularity.lang property from ‘en-US’ to a different language (like hi-In for Hindi or fr-FR for Français). See the whole list of supported languages.

No comments:

Post a Comment

Thanks for u r comment