It is possible to recognize a Hindi speech and show text in the Hindi language using Speech Recognizer. I tried a below code but its always show in English (UK).
Not Want to use any paid API for that
launcherSpeech =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == Activity.RESULT_OK) {
val spokenText: String? =
it.data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
.let { text -> text?.get(0) }
msg?.setText("${msg?.text.toString()} $spokenText")
}
}
R.id.csVoice -> {
val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,"hi-IN")
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale("hi_IN"))
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Listening....")
launcherSpeech?.launch(intent)
}