!747 import android.app.*; import android.content.*; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.speech.RecognitionListener; import android.speech.RecognizerIntent; import android.speech.SpeechRecognizer; import android.widget.Button; import android.widget.TextView; import android.util.Log; import android.media.*; main { static Activity androidContext; static SpeechRecognizer sr; static final String TAG = "MyStt3Activity"; static boolean loop = true; static S language = "de-DE"; static int extraResults = 1; p { androidContext.runOnUiThread(runnable { androidMuteAudio(androidContext); makeNewObject(); }); sleep(); } static void makeNewObject() { sr = SpeechRecognizer.createSpeechRecognizer(androidContext); sr.setRecognitionListener(new listener()); go(); } static class listener implements RecognitionListener { public void onReadyForSpeech(Bundle params) { print("SAG WAS."); } public void onBeginningOfSpeech() { //print("LISTENING."); } public void onRmsChanged(float rmsdB) { //print("onRmsChanged"); } public void onBufferReceived(byte[] buffer) { print("onBufferReceived"); } public void onEndOfSpeech() { //print("RECOGNIZING."); } public void onError(int error) { //print( "error " + error); // screw the errors! //if (loop) go(); try { sr.destroy(); } catch (Throwable e) { print(e); } if (loop) makeNewObject(); } public void onResults(Bundle results) { String str = new String(); //print("onResults " + results); ArrayList data = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); S bestMatch = data.get(0); print("I heard: " + quote(bestMatch)); //print("I heard: " +structure(data)); // TODO: fix the java strings umlaut problem if (match3("goodbye", bestMatch) || match3("bye", bestMatch) || match3("tsch\u00fcss", bestMatch)) { print("\nGOODBYE!"); sr.destroy(); return; } if (loop) { sr.stopListening(); go(); } } public void onPartialResults(Bundle partialResults) { print("onPartialResults"); } public void onEvent(int eventType, Bundle params) { print("onEvent " + eventType); } } static void go() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test"); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, extraResults); sr.startListening(intent); //print("started listening"); } }