Sergii Alekseev
Sergii Alekseev

Reputation: 23

Google SpeechRecognition and W3C Speech API

I'm trying to use google WEB SPEECH API, but I have a problem with taht. I'm new in programming. So I wanna make something like that - https://www.google.com/intl/en/chrome/demos/speech.html

But, when I use examples from API, thre is an error. The object not defined... And I dont know why. I'm trying use this code

 <script type="text/javascript">
    var recognition = new SpeechRecognition();
    recognition.onresult = function(event) {
      if (event.results.length > 0) {
        q.value = event.results[0][0].transcript;
        q.form.submit();
      }
    }
  </script>

  <form action="http://www.example.com/search">
    <input type="search" id="q" name="q" size=60>
    <input type="button" value="Click to Speak" onclick="recognition.start()">
  </form>

Can anyone help my with that??? thx.

Upvotes: 2

Views: 3298

Answers (1)

Nikolay Shmyrev
Nikolay Shmyrev

Reputation: 25220

Google didn't exactly implement W3C API specification, they have minor differences. The object name is webkitSpeechRecognition, not SpeechRecognition. You can find examples on webkit API here:

http://updates.html5rocks.com/2013/01/Voice-Driven-Web-Apps-Introduction-to-the-Web-Speech-API

or here:

http://apprentice.craic.com/tutorials/37

Upvotes: 3

Related Questions