I am using Android SpeechRecognizer and want to limit the number of transcription results returned by Google.
From the EXTRA_MAX_RESULTS documentation in RecognizerIntent it looks like I want:
An additional limit on the maximum number of returned results. If you skip, the recognizer will choose how many results will be returned. Must be an integer.
However, adding this addition to the intent has no effect. Bundle onResults Bundle always has five transcriptions, no matter what number I specify.
public class MainActivity extends AppCompatActivity implements RecognitionListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final SpeechRecognizer recognizer = SpeechRecognizer.createSpeechRecognizer(getApplicationContext()); recognizer.setRecognitionListener(this); final Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 2);
What is the correct way to limit the number of transcriptions that Google returns?
source share