Android ACTION_RECOGNIZE_SPEECH effort never ends after a long speech

I began to wash and waited for the result. It works very well in short speech, but it does not give me an answer to speech if it is too long. (almost 1 min)

final Intent searchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

    searchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "tr");
    searchIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, true);
    searchIntent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, true);

    startActivityForResult(searchIntent, VOICE_REQUEST_CODE);

Is there a way other than SpeechRecognizer to get results from the intent of ACTION_RECOGNIZE_SPEECH?

+4
source share
2 answers

Here's a working solution:

final Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, yourPackageHere);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1000);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Your Prompt");
startActivityForResult(intent,REQUEST_CODE);

But before using this function, you must check whether the user is granted permission RECORD_AUDIOand the device ACTION_RECOGNIZE_SPEECH.

. MAX_RESULTS, . , onActivityResult List<String> results . .

+2

,

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak Now");
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, REQUEST_CODE);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
startActivityForResult(intent,REQUEST_CODE);

, :)

+1

Source: https://habr.com/ru/post/1663637/


All Articles