gpt4 book ai didi

android - RecognizerIntent 不尊重语言

转载 作者:行者123 更新时间:2023-11-30 05:11:51 25 4
gpt4 key购买 nike

我正在尝试让 RecognizerIntent 遵循我设置为收听的自定义语言,但它不起作用。看起来它只是不使用我发送的参数,只考虑系统设置(如果我更改系统的语音搜索设置,它确实有效)。

这就是我创建 Intent 的方式:

val spanish = Locale("es", "ES").toString()
val recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)

recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true)
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, spanish)
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, spanish)
recognizerIntent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, spanish)
recognizerIntent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", arrayOf(spanish))

startActivityForResult(recognizerIntent, REQUEST_SPEECH)

非常感谢任何帮助

最佳答案

 if (sharedPreferences.getAppLanguage() == LANGUAGE_ENGLISH) {
recognizerIntent!!.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())
} else {
recognizerIntent!!.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "ar-AE")
}

关于android - RecognizerIntent 不尊重语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53594168/

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