I have a code in my application which recognize "Persian" language and make a Speech-to-text function:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "fa");
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak...");
but now it’s suddenly stopped working and just recognize my STT as English! I didn’t change anything. When I’m changing RecognizerIntent.EXTRA_LANGUAGE
to any language like Italian intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "it");
it doesn’t recognize this language either!
What’s wrong?
2
Answers
Try explicitly setting the locale with a Locale object instead of just the language code:
or
The default language of the device might be affecting the recognition.
Solution:
Try changing the device’s default language to Persian temporarily:
Go to Settings → System → Languages & Input → Languages.
Add Persian and set it as the primary language.
Restart the device and test your app.
Sometimes permission changes or updates to the Android operating system can cause issues with STT.
Solution:
Ensure your app has the necessary permissions for recording audio and using the microphone:
xml
Check if runtime permissions are granted: