Question

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.

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top