Skip to content Skip to sidebar Skip to footer

Android Speech To Text Handling

in softkeyboard i have the option for speech to text , when i spoke it show a list of suggestion , when i select a text ,i need to fill my editText with this text, how can i done t

Solution 1:

Assuming your text edit is named "te":

publicvoidonResults(Bundle results) {   
  ArrayList<String> voiceResults = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
  StringBuilder sb = newStringBuilder();
  for(Stringp: voiceResults)   {
    sb.append(p);
    sb.append("\n");   }   te.setText(sb.toString()); 
  }

Normally, you are only interested in the first result (i.e voiceResults (0)) since that is the most probable match but the code above shows all of them so you can see what is returned.

Post a Comment for "Android Speech To Text Handling"