android - how to get a single result from a voice recognizer with out "["and "]" in the start and the end of result -


I am using a voice identifier in my app. But I Speech recognizer not "[" and "]" results should receive voice identifier.

Currently I have a code that gives me a result but gets in front of it and in the result "[" and "]".

Please check your code to make possible corrections and modifications and apppriate answers I am very new to Android.

code: MainActivity.java

  Import JavakutilkArrayList; Import android App Import android.content.Intent; Importroid.os.Bundle; Import android.speech.RecognizerIntent; Import android.view.View; Import android.widget.Button; Import android.widget.TextView; Public Classroom increases main activity activity {Personal Static FINAL end RECOGNIZER_EXAMPLE = 1001; Private Text Viv TV; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.activity_main); Tv = (TextView) findViewById (R.id.text_result); // Set Up Button Listener Button Start Button = (Button) Find ViviIID (RID Trigger); StartButtonksetOnClickListener (See New. OnClickListener () {@Override public click on zero (arg 0) {// TODO been auto-generated method stub effect intended = new Intent (Phchankrtaaiantient. Akshn_osijianaijisopiiiiaf); effect. Inputaktara (Phchankrtaaitint. EXTRA_LANGUAGE_MODEL, Phchankrtaintrent LANGUAGE_MODEL_FREE_FORM); intent.putExtra (RecognizerIntent.EXTRA_PROMPT, "say a word or phrase, and it will be shown as text"); effect. input extras (Ricoijr Ini Tents. EXTRA_MAX_RESULTS, 1); startActivityForResult (mean, RECOGNIZER_EXAMPLE);}}); } @Override zero onActivityResult (integer requestCode, integer resultCode, intent data) {// Protect uses a switch statament to investigate more request code, then (requestCode == RECOGNIZER_EXAMPLE & amp; & amp; resultCode = = RESULT_OK) {// The given data is a list of matches for the speech ipot array list & lt; String & gt; Results = Data. GetStringArrayListExtra (RecognizerIntent.EXTRA_RESULTS); Tv.setText (result.toString ()); } Super.onActivityResult (requestCode, ResultsCode, Data); }}  

  @override zero onActivityResult protected (integer requestCode, integer resultCode, Intent data) {// More than one request code uses a switch statament to check if (requestCode == RECOGNIZER_EXAMPLE & amp; resultCode == RESULT_OK) {// given data speech iput ArrayList & Lt is a list of matches, string & gt; Results = Data. GetStringArrayListExtra (RecognizerIntent.EXTRA_RESULTS); // Results Here is an array list, we need any element to look in the textView TVs .set text (result.get (0) .toString ()); } Super.onActivityResult (requestCode, ResultsCode, Data); }  

So we have to change

  tv.setText (result.toString ());  

for

  tv.setText (result.get (0) .toString ());  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -