Konuşma tanıma için Google API kullanıyorum, ancak dinleme süresini sınırlamak istiyorum. Örneğin iki saniye. Kullanıcı iki saniyeden sonra tanımaya devam etse bile tanıyıcı dinlemeyi bırakmalı. BenAndroid - Konuşma Tanıma Sınırlama Dinleme Süresi
EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS
gibi bazı ekstralar denedik ama bana yardımcı olmadı. Benim tam kod kimse bana yardımcı olabilir, ben
public void promptSpeechInput()
{
//This intent recognize the peech
Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
i.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say Something");
try {
startActivityForResult(i, 100);
}
catch (ActivityNotFoundException a)
{
Toast.makeText(MainActivity.this,"Your device does not support",Toast.LENGTH_LONG).show();
}
}
//For receiving speech input
public void onActivityResult(int request_code, int result_code, Intent i)
{
super.onActivityResult(request_code, result_code, i);
switch (request_code)
{
case 100: if(result_code == RESULT_OK && i != null)
{
ArrayList<String> result = i.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
resultTEXT.setText(result.get(0));
}
break;
}
}
Teşekkürler Francisco, deneyeceğim – ysfcyln