15

We're using the webkitSpeechRecognition API in Chrome. Since this is a prototype application, we're quite happy to support only Chrome, so we detect support for the API by doing a window.hasOwnProperty('webkitSpeechRecognition') check (as suggested by Google). This happily fails in Firefox, but the new Opera (being webkit-based) reports it does have the property. And, indeed, all code runs as intended, except... none of the events are ever fired, no voice is ever recorded.

So, my question is: can I make it work somehow? Does it require some special permissions or settings?

Alternatively, is there a way (aside good old browser-sniffing) to detect proper, working support for the webkitSpeechRecognition?

SáT
  • 3,633
  • 2
  • 33
  • 51
  • Did you find an alternative to browser-sniffing? I am facing the very same problem – Oscar Hermosilla Dec 14 '16 at 12:33
  • @OscarHermosilla no, unfortunately. It wasn't critical to us, so I wasn't looking very actively. But I'm curious, let me just put up a bounty. – SáT Dec 14 '16 at 12:51

2 Answers2

5

Right now only google chrome have API to speech recognition by stream (they have google sppeech API).

If you will use https://www.google.com/intl/en/chrome/demos/speech.html on Opera it will tell you that you need Chrome25+ to do this.

Acording to http://caniuse.com/#feat=speech-recognition Opera webkit have support for this functionality but right now it is not working. Opera does not have any API service that would translate it on the fly. Right now there have only placeholders function in their browser, maybe in the future they will make it, right no it is not working.

* EDITED *

Example by google how to determinte if it working or not.

// checking by google
if (!('webkitSpeechRecognition' in window)) {
  console.log('GOOGLE: not working on this browser');
} else {
  console.log('GOOGLE: working');
}

//your way
if (window.hasOwnProperty('webkitSpeechRecognition')) {
  console.log('YOUR: working');
} else {
  console.log('YOUR: not working on this browser');
}
Michał Ignaszewski
  • 1,124
  • 12
  • 11
  • 1
    I'm using Opera build 41.0.2353.69, and the speech demo page just plain doesn't work, without telling me anything. And I chuckled how caniuse.com reports it as "partial support", same as Chrome. At any rate, is there a way to detect that it's just a placeholder function? (And why on earth don't they just throw an exception or something instead of dying silently?) – SáT Dec 14 '16 at 15:53
  • webkitSpeechRecognition - tries to find default speech recognition software to work. Chrome by default is streaming by chrome to google speech API to recognize speech (thats why you have so many languages that could be recognized). On mobiles there is usualy speech recognition software, Opera on that mobile device should work, on desktop it is not working. I hope that will help. – Michał Ignaszewski Dec 14 '16 at 16:03
  • I added example from google demo page, very similar to window.hasOwnProperty but maybe it is making a difference, it detects webkit on my Chrome, but not in my Opera 42. – Michał Ignaszewski Dec 14 '16 at 16:16
  • I'll be damned, using an Opera 42.0.2393.85, I get working/working. You don't? Weird. And... no, I don't think hasOwnProperty or a simple property check should make a difference. – SáT Dec 17 '16 at 19:44
  • I'm using Ubuntu 16.04.1, Opera 42.0.2393.85. I think that maybe on your OS there is some speech recognition software installed and Opera see it. – Michał Ignaszewski Dec 19 '16 at 15:03
  • Accordnig to http://www.opera.com/help/tutorials/voice/using/ build voice recognition works only on Windows XP or 2000 or higher (so it need MS build speech to text program). I think the same logic is for webkitSpeechRecognition. – Michał Ignaszewski Dec 19 '16 at 15:13
1

The following Google sample uses a timestamp to detect that Opera did not trigger the start event: https://www.google.com/intl/en/chrome/demos/speech.html

jlchereau
  • 1,152
  • 1
  • 7
  • 5