Saturday, August 20, 2011

How to Add Speech Recognition to your Website

1 Comment so far

By punemsexesena



speech_input
Your website pages probably contain a few text fields that require user input. For instance, your site may have a search box where people type in search queries, a comment form (commonly found in blogs) while some sites have a contact form that visitors can use to quickly send a message to the author /webmaster.
The visitors to your website currently need to use the keyboard to enter text in the various input fields but wouldn’t it be nice if you could also offer them an alternate form of input where they can just speak instead of typing?
Well all you need to do is add an extra word – highlighted in red - to your existing search code and your site will able to accept voice based input.

Add Speech Input to your Search Box

<form method="get" action="http://www.google.com/search">
 <input type="text" name="q" size="30" x-webkit-speech />
 <input type="submit" value="Google Search" />
</form>

Try a live demo - click the microphone icon, speak and hit enter:  
You may also find a live speech-enabled search box on the site’s homepage. When you are done speaking, the audio is sent to Google servers where it gets transcribed and delivered as plain text.
Currently, only Google Chrome supports the HTML speech input API and thus, the microphone icon will only be visible to users who are accessing your site through Chrome. If they are using a different browser, they’ll see the standard search box.
The speech input attribute that does all the magic - x-webkit-speech - works with <input> fields only but there’s an easy workaround that will help you enable voice support for any other text field the <textarea> tag.

Add Speech Input to any Textarea like Comment Forms

Speech input for textarea - click the microphone icon and talk:  




The code looks something like this:

<script type="text/javascript">
  function transcribe(words) {
    document.getElementById("speech").value = words;
    document.getElementById("mic").value = "";
    document.getElementById("speech").focus();
  }
</script>

<textarea cols="50" id="speech" ></textarea>
<input id="mic" onwebkitspeechchange="transcribe(this.value)" x-webkit-speech>
Internally, when you click the microphone icon and speak, the transcribed text still goes into the <input> field but with the help of a JavaScript function, a copy of that text is instantly sent to the textarea as well.
The above trick will come handy in case you wish to voice-enable the comment form or the email form of your website that accept long-form text.

Tuesday, August 16, 2011

Cornered govt to release Anna from Tihar after public backlash

Be the first to comment!

Anna HazareBy punemsexesena : Protests all over India brought the UPA government to its knees on Tuesday night, forcing a decision to release social activist Anna Hazare barely hours after he had been sent to Tihar Jail for seven days.

Anna Hazare and some of his close associates were arrested earlier in the day after they made it clear they would defy all prohibitory orders and carry on an indefinite fast demanding a strong Lokpal Bill.

The 73-year-old Gandhian was picked up at 7.30 am from a flat where he was staying in Mayur Vihar in East Delhi after he refused to be persuaded by Delhi Police officials against the fast, in violation of prohibitory orders that were imposed
last night.

Anna Hazare had even refused food in Tihar, indicating he would carry on his fast in jail.

Hazare and his aides including, Kiran Bedi and Arvind Kejriwal, were first taken to the Delhi Police Officers' Mess in North Delhi and were shifted to another after Hazare's supporters gathered in large numbers at Civil Lines.

Nearly 1,400 activists were detained in various parts of the city when they came out in support of Hazare, who had planned to launch the fast at Jai Prakash Narain Park near Ferozeshah Kotla.

The social activist, who is campaigning for a legislation that will cover the Prime Minister, higher judiciary and MPs' conduct within Parliament among other things, was later taken to Rajouri Garden police station in West Delhi where a Special Executive Magistrate remanded him to 7 days judicial custody.

Related Posts Plugin for WordPress, Blogger...