2

I am working on an android application where the application listens for the Japanese words and translate it into English and prints it on the screen.

I am using the Google Speech To Text Listener. But the problem is that it stops listening after a few seconds and I have to start the listener again.

Moreover, Is it possible to get a single accurate result rather than an array from the Listener?

This is my intent initialization code.

intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
                String jap=sharedpreferences.getString("jap","");

                //Putting Japanese intent to Voice Recognition if the locale is set to japanese
                if(jap!=""){
                    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,"ja-JP" );                }
                else
                    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.ENGLISH);

                intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test");
                intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,15);
                sr.startListening(intent);
4

0 回答 0