Voice recognition on android with recorded sound clip?

I used the voice recognition feature on Android and I like it. This is one of the most meritorious features of my clients. However, the format is somewhat restrictive. You need to call the intent of the recognizer, send it for transcription in google and wait for the text to return.

Some of my ideas will require recording audio in my application and then sending the clip to google for transcription.

Is there a way to send an audio clip that will be processed with speech to text?

+29
android speech-recognition voice-recognition voice
Feb 23 '10 at 16:15
source share
3 answers

I have a solution that works well for speech recognition and sound recording. Here is a link to a simple Android project that I created to show how the solution works. In addition, I put several print screens in the project to illustrate this application.

I will try to briefly explain the approach that I used. I combined two functions in this project: Google Speech API and Flac entry.

The Google Speech API is called through HTTP connections. Mike Pultz gives more details about the API:

"(...) the new [Google] API is a full duplex streaming API. This means that it actually uses two HTTP connections - one POST request to download the content as a" live "fragmented stream, and a second GET request for access to results, which is more important for longer audio samples or for streaming audio.

However, this API must receive a FLAC sound file for it to work properly. This makes us move on to the second part: writing flags

I implemented a Flac entry in this project by extracting and adapting some code snippets and libraries from an open source application called AudioBoo. AudioBoo uses its own code to record and play flac format.

Thus, you can record flac sound, send it to the Google Speech API, receive text and play the recorded sound.

The project that I created has basic principles to make it work and can be improved for specific situations. To make it work in a different scenario, you need to get the Google Speech API key, which is obtained as part of the Google Chromium-dev group. I left one key in this project to show its work, but in the end I will delete it. If someone needs more information about this, let me know because I cannot post more than two links in this post.

+10
Apr 17 '14 at 21:22
source share

Unfortunately, no at this time. The only interface currently supported by the Android voice recognition service is RecognizerIntent , which prevents you from providing your own audio data.

If this is what you would like to see, write a feature request at http://b.android.com . This is also indirectly related to existing issue 4541 .

+3
Feb 23 '10 at 19:49
source share

As far as I know, there is still no way to directly send an audio clip to Google for transcription. However, Froyo (API level 8) introduced the SpeechRecognizer class, which provides direct access to the speech recognition service. So, for example, you can start playing an audio clip and start your activity with speech recognition in the background, which will return the results after completion to the user-defined method of calling the listener back.

The following code example should be defined as part of the Activity, as the SpeechRecognizer methods must be run in the main application thread. You will also need to add the RECORD_AUDIO permission to your AndroidManifest.xml.

 boolean available = SpeechRecognizer.isRecognitionAvailable(this); if (available) { SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(this); sr.setRecognitionListener(new RecognitionListener() { @Override public void onResults(Bundle results) { // process results here } // define your other overloaded listener methods here }); Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); // the following appears to be a requirement, but can be a "dummy" value intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.dummy"); // define any other intent extras you want // start playback of audio clip here // this will start the speech recognizer service in the background // without starting a separate activity sr.startListening(intent); }
boolean available = SpeechRecognizer.isRecognitionAvailable(this); if (available) { SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(this); sr.setRecognitionListener(new RecognitionListener() { @Override public void onResults(Bundle results) { // process results here } // define your other overloaded listener methods here }); Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); // the following appears to be a requirement, but can be a "dummy" value intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.dummy"); // define any other intent extras you want // start playback of audio clip here // this will start the speech recognizer service in the background // without starting a separate activity sr.startListening(intent); } 

You can also define your own speech recognition service by extending the RecognitionService , but this is beyond the scope of this answer :)

+1
Feb 19
source share



All Articles