首页 > 解决方案 > ML Kit ASR 错误:错误代码:40,子错误代码:3005,错误消息:服务不可用

问题描述

我一直在开发语音识别演示并遇到了问题。有人可以帮我吗?我调用startRecognizing了接口并收到了一个 onError 回调(错​​误 11203,子错误 3005,错误消息:服务不可用),看截图:

我按照文档,我的代码:

// Create an Intent to set parameters.
val mSpeechRecognizerIntent = Intent(MLAsrConstants.ACTION_HMS_ASR_SPEECH)
// Use Intent for recognition parameter settings.
mSpeechRecognizerIntent 
// Set the language that can be recognized to English. If this parameter is not set, English is recognized by default. Example: "zh-CN": Chinese; "en-US": English; "fr-FR": French; "es-ES": Spanish; "de-DE": German; "it-IT": Italian; "ar": Arabic; "th_TH": Thai; "ms_MY": Malay; "fil_PH": Filipino.
.putExtra(MLAsrConstants.LANGUAGE, "en-US") // Set to return the recognition result along with the speech. If you ignore the setting, this mode is used by default. Options are as follows:
// MLAsrConstants.FEATURE_WORDFLUX: Recognizes and returns texts through onRecognizingResults.
// MLAsrConstants.FEATURE_ALLINONE: After the recognition is complete, texts are returned through onResults.
.putExtra(MLAsrConstants.FEATURE, MLAsrConstants.FEATURE_WORDFLUX) // Set the application scenario. MLAsrConstants.SCENES_SHOPPING indicates shopping, which is supported only for Chinese. Under this scenario, recognition for the name of Huawei products has been optimized.
.putExtra(MLAsrConstants.SCENES, MLAsrConstants.SCENES_SHOPPING)
// Start speech recognition.
mSpeechRecognizer.startRecognizing(mSpeechRecognizerIntent)

你知道为什么会发生这种情况吗?请帮忙,谢谢!!

标签: androidkotlinmachine-learninghuawei-mobile-serviceshuawei-ml-kit

解决方案


您需要更改"en-US""zh-CN".

或注释掉".putExtra(SCENES, SCENES_SHOPPING)"

在此处输入图像描述


推荐阅读