问题
I am currently working on a project in ASP.NET. I need to add voice command which will work on IE/Chrome/Firefox. I have searched a lot, but haven't found any solutions for cross browser.
Is there any JavaScript framework to do it? Can i use Google web speech API as a service?
Any suggestion will be helpful.
回答1:
You can check support for speech recognition in various browsers at Can I Use. At the moment only Chrome supports speech recognition reliably. Others don't, including IE, Firefox and Safari. Firefox is working on the speech recognition support, but it's not there yet.
If your browser supports getUserMedia to record audio you can record the audio and send it to the server for recognition. You can also use javascript-only recognizer Pocketsphinx.js if you want to recognize few simple commands.
On browsers which do not support getUserMedia API you can use Flash object or java applet to capture audio. That's pretty much your only option if you prioritize IE.
回答2:
It can be done as long as the browser supports HTML5's getUserMedia API:
- Use HTML5's getUserMedia to capture an audio stream
- Save it to .WAV, there are libraries for that
- Send the .WAV to the server through AJAX
- Feed the .WAV to SpeechRecognitionEngine, through the SetInputToWaveFile method
- Get the result and return it in the AJAX call
An example:
http://weblogs.asp.net/ricardoperes/speech-recognition-in-asp-net
来源:https://stackoverflow.com/questions/25789249/cross-browser-speech-recognition