gpt4 book ai didi

android - 如何为 SpeechRecognizer Google SpeechToText APi 设置土耳其语

转载 作者:行者123 更新时间:2023-11-29 19:45:39 27 4
gpt4 key购买 nike

在我的应用程序中,我正在尝试创建一个从文本到语音的语音识别器 google Api for turkish 并将 EXTRA_LANGUAGE_PREFERENCE 作为“tr_TR”传递以识别并返回土耳其语结果,但它以英语识别但不是土耳其语。

String lang_code="tr_TR";    
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE,
lang_code);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, lang_code);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerInt

ent.EXTRA_MAX_RESULTS, 3);

最佳答案

我在我的代码中解决了这个问题:

        language = "tr-TR";

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, language);
intent.putExtra(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES, language);
intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, language);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, language);
intent.putExtra(RecognizerIntent.EXTRA_RESULTS, language);
startActivityForResult(intent, REQUEST_CODE);

关于android - 如何为 SpeechRecognizer Google SpeechToText APi 设置土耳其语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37772888/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com