Example usage for android.speech SpeechRecognizer RESULTS_RECOGNITION

List of usage examples for android.speech SpeechRecognizer RESULTS_RECOGNITION

Introduction

In this page you can find the example usage for android.speech SpeechRecognizer RESULTS_RECOGNITION.

Prototype

String RESULTS_RECOGNITION

To view the source code for android.speech SpeechRecognizer RESULTS_RECOGNITION.

Click Source Link

Document

Key used to retrieve an ArrayList from the Bundle passed to the RecognitionListener#onResults(Bundle) and RecognitionListener#onPartialResults(Bundle) methods.

Usage

From source file:com.onebus.view.MainActivity.java

public void onResults(Bundle results) {
    long end2finish = System.currentTimeMillis() - speechEndTime;
    status = STATUS_None;/*from w  w  w .  j  av a2 s  .c o  m*/
    ArrayList<String> nbest = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    /*
     * print("?" + Arrays.toString(nbest.toArray(new
     * String[nbest.size()])));
     */

    Intent intent = new Intent();
    intent.setClass(getApplicationContext(), SearchActivity.class);
    intent.putExtra("tag", 1);
    intent.putExtra("strMessage", nbest.get(0).toString());
    startActivity(intent);

    String json_res = results.getString("origin_result");

    String strEnd2Finish = "";
    if (end2finish < 60 * 1000) {
        strEnd2Finish = "(waited " + end2finish + "ms)";
    }

    cancel();
}

From source file:com.onebus.view.MainActivity.java

public void onPartialResults(Bundle partialResults) {
    ArrayList<String> nbest = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if (nbest.size() > 0) {
        // print("~" + Arrays.toString(nbest.toArray(new
        // String[0])));

    }/*w w w .jav a 2  s .  c  o m*/
}

From source file:cn.jasonlv.siri.activity.MainActivity.java

@Override
public void onPartialResults(Bundle partialResults) {
    ArrayList<String> nbest = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if (nbest.size() > 0) {
        print("~" + Arrays.toString(nbest.toArray(new String[0])));
        //txtResult.setText(nbest.get(0));
    }/*from  w w  w .  j  av a 2 s  .com*/
}

From source file:com.wizardsofm.deskclock.alarms.AlarmActivity.java

@Override
public void onResults(Bundle data) {

    resumeCounting = false;//from ww  w .  j  a  v  a  2 s .  c  o  m

    ArrayList<String> matches = data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);

    makeText(this, getResources().getString(R.string.you_said) + matches.get(0), Toast.LENGTH_SHORT).show();

    if (matches.get(0).toUpperCase().contains("SHUTUP".toUpperCase())
            || (matches.get(0).toUpperCase().contains("SHUT UP".toUpperCase()))) {
        snooze();
        speech.cancel();
    } else if (matches.get(0).toUpperCase().contains("STOP".toUpperCase())) {
        dismiss();
        speech.cancel();
    } else {
        speech.cancel();
        speech.startListening(intent);
        resumeCounting = true;
    }
}

From source file:com.cwp.cmoneycharge.activity.AddPayActivity.java

@Override
public void onResults(Bundle results) {
    //?//from ww  w  .  j  ava 2  s  .  co m
    status = STATUS_None;
    ArrayList<String> nbest = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    //print("?" + Arrays.toString(nbest.toArray(new String[nbest.size()])));
    String json_res = results.getString("origin_result");
    try {
        Toast.makeText(AddPayActivity.this, "origin_result=\n" + new JSONObject(json_res).toString(4),
                Toast.LENGTH_SHORT).show();
    } catch (Exception e) {
        Toast.makeText(AddPayActivity.this, "origin_result=[warning: bad json]\n" + json_res,
                Toast.LENGTH_SHORT).show();
    }
}

From source file:com.cwp.cmoneycharge.activity.AddPayActivity.java

@Override
public void onPartialResults(Bundle partialResults) {
    //?//from  w  w  w .  j ava  2s  . c  o m
    ArrayList<String> nbest = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if (nbest.size() > 0) {
        Toast.makeText(AddPayActivity.this,
                "~" + Arrays.toString(nbest.toArray(new String[0])), Toast.LENGTH_SHORT)
                .show();
        //Toast.makeText().setText(nbest.get(0));
    }
}

From source file:org.botlibre.sdk.activity.ChatActivity.java

@Override
public void onResults(Bundle results) {
    debug("onResults:");
    muteMicBeep(false);// w  ww  .  j av  a 2s. co m
    List<String> text = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    this.textView.setText(text.get(0));
    submitChat();
}