我正在尝试实现 Android 的 SpeechRecognizer 功能。由于我公司的隐私限制,数据必须明确不要离开设备 .
至今:
SpeechRecognizer.createSpeechRecognizer
实现了 SpeechRecognizer 类。方法。当我在没有互联网的情况下尝试它时,它工作得很好!但是,据我所知,谷歌不会在在线时发送数据,如果不是为了转录,然后是为了改进他们的音频训练数据。
SpeechRecognizer.createOnDeviceSpeechRecognizer
- 这适用于 Android 12 及更高版本。假设我不介意。但是,它仅适用于特定设备,即。 Pixel 6 但甚至在 Pixel 4a 中也没有。 putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true)
- 这也不起作用。它一直给我错误:ERROR_NO_MATCH
,在我尝试过的任何设备中。 所以这给我们留下了简单的
SpeechRecognizer.createSpeechRecognizer
我的实现是这样的:var recognizerIntent: Intent? = null
if (SpeechRecognizer.isRecognitionAvailable(applicationContext)) {
sr = SpeechRecognizer.createSpeechRecognizer(applicationContext)
val listener = MySpeechRecognitionListener(scopeProvider, lifecycleScope, {
...
}
sr.setRecognitionListener(listener)
recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH)
}
sr.startListening(recognizerIntent)
} else {...}
问题:我们能否以某种方式保证 Android 的 SpeechRecognizer 不会向 Google 发送数据?
最佳答案
利用:
public static SpeechRecognizer createSpeechRecognizer (Context context,
ComponentName serviceComponent)
指定 serviceComponent
那是开源的,因此您可以验证它不会向 Google 发送数据。我没有看到任何其他解决方案,即我不知道任何 Android API 标志,如
DONT_SEND_DATA_TO_GOOGLE
.
关于android - 我们能保证 Android 的 SpeechRecognizer 不会向 Google 发送数据吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70127164/