Voice recognition in the app

The program, when recognizing the voice, displays an array of similar words on the screen. Is it possible to make it so that the output is not an array of words,but the spoken word? If so, how?

emailText = findViewById(R.id.email_text);
private static final int Print_Words = 100;
Button mButton = (Button) findViewById(R.id.button);
    mButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {

            //Вызываем RecognizerIntent для голосового ввода и преобразования голоса в текст:
            Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
            intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Скажите слово для распознавания");
            startActivityForResult(intent, Print_Words);
        }
    });
 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    //Проверяем успешность получения обратного ответа:
    if (requestCode == Print_Words && resultCode == RESULT_OK) {
        //Как результат получаем строковый массив слов, похожих на произнесенное:
        ArrayList<String> result=data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        //и отображаем их в элементе TextView:
        assert result != null;
        emailText.setText(result.toString());
    }
    super.onActivityResult(requestCode, resultCode, data);
}
Author: Эникейщик, 2020-02-22

1 answers

Since this is an array, we simply output its first (in the array zero) result, because the first (zero) place is the most similar to the above result.
emailText.setText(result.get(0));

 1
Author: Unknown3-3-3, 2020-02-24 17:31:02