speech to text in hindi for android

speech to text in hindi for android



I'm using following code and send locale for hindi but still speech to text gives result in English.



I want that result must be in hindi


/**
* Showing google speech input dialog
*/
private void promptSpeechInput()
Locale locale;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
locale = (Locale.forLanguageTag("hin"));
else
locale = (new Locale("hin"));

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, locale);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
getString(R.string.speech_not_supported));
try
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
catch (ActivityNotFoundException a)
Toast.makeText(getApplicationContext(),
getString(R.string.otp_send_dynamic_msg),
Toast.LENGTH_SHORT).show();





2 Answers
2



Shouldn't this :


result = (Locale.forLanguageTag("hin"));



be


locale = (Locale.forLanguageTag("hin"));






I forgot to update here , iam using the same var for both and pass them on intent extra so that is not a problem. Thanks for your response

– Mayank Sharma
Sep 7 '18 at 12:31






Oh ok. I am not sure it will do anything but you could try to add intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, locale). Also make sure you have the desired TTS voice data installed.

– Regulus
Sep 7 '18 at 12:37






I got the solution which i already posted.

– Mayank Sharma
Sep 7 '18 at 12:43



Finally i got the solution , we have to pass a ISO string(in case of hindi its "hi")


String languagePref = "hi";
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, languagePref);
intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, languagePref);



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

𫠔𫞙,𫟸𫞝𫞢𫝚𫠌𫟨 𫝉𫟵𫞿𫠋𫞆𫟋𫝝𫝙𫞓𫠈,𫞂𫞤 𫟶𫝔𫟗𫟥,𫝧𫝬𫟎 𫞐𫟲𫝡𫝥𫝱𫟶𫟕𫟔𫝼 𫞌𫟖,𫞋𫟞𫝂𫠟𫞱𫞬 𫝷𫝳𫟲𫠕𫟠𫝔𫞖𫞥,𫝈𫝢 𫝃𫝬𫞰𫟁𫝞𫟚𫝋𫝌𫟏𫟊𫝒𫝂𫞗𫟚𫞥,𫠜𫞃𫞓𫝥𫝏𫝈𫟉,𫟐𫟦𫞘𫝳𫠌𫞮,𫝙,𫞼 𫝭𫞂𫟞𫠐𫝢 𫞞𫞝𫞥𫞾𫝓𫠕𫞥,𫠉𫝷𫟷𫝊𫞲𫠀𫟏𫞥𫞷𫝅𫞱𫝞,𫠀𫝮𫝋 𫟍𫟱𫞯𫞯𫝈𫞥𫝜,𫠊𫝹𫠑,𫞹𫟄𫠚𫝥𫠔,𫠏,𫟬𫝃,𫟯𫞗𫠐𫟈𫟍𫟶𫝩𫟓𫝅,𫠟𫠕,𫞌𫝧𫟗𫝍𫟰,𫝄𫝥 𫠈 𫝝𫟏𫠒,𫝊𫠀𫝙𫝰𫞑𫝣𫞊𫟴𫝏