android - 西班牙语 Kotlin 语音识别
问题描述
我想在 Kotlin 中制作一个语音识别应用程序。当我设置“en-US”语言时,一切正常,但当我设置“es-ES”时,语音识别永远不会结束。onPartialResults 在我说话时给了我一些结果,但永远不会调用 onResults,并且识别永远不会结束。仅当我设置“es-ES”时。如果我设置“en-US”,则会调用 onResults 并完美识别。我已经下载了 en-US 语言和 es-ES 语言,以便在我的配置中进行离线识别。
发生什么事?我需要帮助
我的代码:
val language = "es-ES" //"en-US"
val speech: SpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(activity)
speech.setRecognitionListener(this)
intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language)
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, language)
intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, language)
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true)
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 2)
speech.startListening(intent)
谢谢
解决方案
推荐阅读
- python - 为什么这段代码不会删除我在 Python 中的反斜杠?
- python-2.7 - 无法更新更改 GPIO 引脚的图像
- c++ - 方法不会覆盖父亲的方法
- javascript - lightbox2 图像库根本不起作用
- firefox - Firefox 扩展:通过 url 显示 iframe
- intellij-idea - 在 IntelliJ 的代码编辑器中,将所选文本用双引号括起来
- linux - 构建程序时linux头文件中的错误
- sql-server - 变量为空时选择空数据 SQL Server
- node.js - MongoDB - 创建文档 30 分钟后更新文档
- mysql - 在类别旁边显示所有类别以及该类别中的帖子数