Search code examples
csshtmlwebkitspeech

How Create Search Engine Which Search Automatically After Voice Recognition


Possible Duplicate:
jQuery HTML5 Speech Input

I want create an search engine for my site which will use Speech Recognition, x-webkit-speech code, but the thing is i want as soon as users speaks query and it recognize it has to search automatically currently users has to press Search button or hit enter button, i am using following code :-

<form method="get" action="http://www.mysite.com/search/"> <input type="speech" id="speech" name="i" size="50" x-webkit-speech /> <input type="submit" value="Search" /> </form>

Can you plz tell me what i need to add and where


Solution

  • I'd recommend you use the JQuery library: http://jquery.com/

    Simply add this code to your header:

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    

    Add then add this line to your JavaScript file:

    $(document).ready(function()
    {
        $('#speech').bind('webkitspeechchange',function()
        {
            $(this).parent('form').submit();
        });
    });