Not getting RecognizerIntent result codes

by pac » Fri, 23 Apr 2010 01:18:44 GMT


Sponsored Links
 I want to get the RecognizerIntent result codes such as
RESULT_SERVER_ERROR because I want to distinguish between the cases
where the speech wasn't understood or no matches were found and the
cases where recognition didn't occur because of connection or server
problems.

When onActivityResult() executes, however, the result code is either
RESULT_OK or 0.  I never catch any of the various RecognizerIntent
result codes.  What do I need to do?

Here's my code:

  private void startVoiceRecognitionActivity() {
        Intent intent= new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say something!");
        startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
    }

    protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
        if (requestCode == VOICE_RECOGNITION_REQUEST_CODE &&
resultCode == RESULT_OK) {
              // do stuff
        }
        else if (requestCode == VOICE_RECOGNITION_REQUEST_CODE &&
resultCode != RESULT_OK) {

                // Figure out the error
                String err = "";
                switch (resultCode) {
                case (RecognizerIntent.RESULT_AUDIO_ERROR):
                        err = "Audio error";
                break;
                case (RecognizerIntent.RESULT_CLIENT_ERROR):
                        err = "Client error";
                break;
                case (RecognizerIntent.RESULT_NETWORK_ERROR):
                        err = "Network error";
                break;
                case (RecognizerIntent.RESULT_NO_MATCH):
                        err = "No match";
                break;
                case (RecognizerIntent.RESULT_SERVER_ERROR):
                        err = "Server error";
                break;
                }
       }
        super.onActivityResult(requestCode, resultCode, data);
    }

--



Other Threads

1. Audio streaming/progressive download over HTTP

Hi All,

I have a couple questions regarding audio streaming/progressive
download over
HTTP. Could you please help me?

1. MediaPlayer supports progressive download according to the
developer guide from
this link http://developer.android.com/guide/topics/media/index.html
("If you're
passing a URL to an online media file, the file must be capable of
progressive
download."). As far as I understand progressive download means media
playback during
download process with saving the media file to file system(SD card or
internal FS) after
the downloading is finished (if it's a file, not a stream in the
passed URL).
So, I tried to set the following URL: setDataSource
(http://84.204.154.49/mmapi/music.mp3). Playback is fine, but the file
isn't saved to
SD card or internal phone file system. Can MediaPlayer save media
content to the file system
after downloading is completed? Is there a way to turn on such
capability?


2. Does MediaPlayer support HTTP streaming? I tried to use
http://217.10.32.134:8129/ultrafan128.mp3, http://62.32.66.180:8800,
also AMR-, AAC-
audio stream over HTTP on the local server, but playback does not
work. For example,
RTSP streaming works fine with AMR and AAC.


Thank you,
   Alexander
--~--~---------~--~----~------------~-------~--~----~

2. How to set up the execution classpath for custom deployed jars

Hi,

I'm trying to port OSGi to Android. I've been successful by copying
the OSGi framework to the directory /data/osgi in the Android emulator
(after some fixes) and I can execute OSGi with the Android shell.

Now, I want to progress a bit more and add Android support. I plan to
create an Android application which launches the OSGi framework, but I
wouldnt like to bundle all the OSGi jars into the Android
applications. I would like that these jars keep located in the /data/
osgi directory. The problem is how to set up the Android application
classpath so that the application can access to the OSGi classes.

I've seen that you can specify the classpath for Android libraries
(e.g. maps) but it's not a full path, and it looks like I need a
classpath with several full paths pointing to /data/osgi.

Any help will be welcome.

Thank you in advance,
Jaime

--~--~---------~--~----~------------~-------~--~----~

3. browser intent messages and broadcastReceiver

4. The app got crashed on SDK 1.5 which is working fine on SDK 1.0

5. Writting/Reading Sync settings - Possible?

6. android create avd - usage in ant

7. Redial