plus.speech.startRecognize({
engine: 'baidu',
lang: 'zh-cn',
'userInterface': true,
'continue': true
}, res => {
console.log(res)
}, err => {
console.log(err)
});
- 发布:2026-01-26 14:13
- 更新:2026-01-27 16:26
- 阅读:115
产品分类: HTML5+
HBuilderX版本号: 4.87
手机系统: iOS
手机系统版本号: iOS 15
手机厂商: 苹果
手机机型: iPhone6s
打包方式: 云端
示例代码:
操作步骤:
plus.speech.startRecognize({
engine: 'baidu',
lang: 'zh-cn',
'userInterface': true,
'continue': true
}, res => {
console.log(res)
}, err => {
console.log(err)
});
plus.speech.startRecognize({
engine: 'baidu',
lang: 'zh-cn',
'userInterface': true,
'continue': true
}, res => {
console.log(res)
}, err => {
console.log(err)
});
预期结果:
正常聆听说话
正常聆听说话
实际结果:
报错:
{
"code": 2225220,
"message": "Error Domain=33 Code=2225220 \"asr authentication failed[info:-3004] [(-3004)] \" UserInfo={NSLocalizedDescription=asr authentication failed[info:-3004] [(-3004)] , NSHelpAnchor=CDC93E37-74A2-469A-9D5E-7D908562363E},https://ask.dcloud.net.cn/article/282"
}
报错:
{
"code": 2225220,
"message": "Error Domain=33 Code=2225220 \"asr authentication failed[info:-3004] [(-3004)] \" UserInfo={NSLocalizedDescription=asr authentication failed[info:-3004] [(-3004)] , NSHelpAnchor=CDC93E37-74A2-469A-9D5E-7D908562363E},https://ask.dcloud.net.cn/article/282"
}
bug描述:
苹果手机执行下边的代码,会报错
plus.speech.startRecognize({
engine: 'baidu',
lang: 'zh-cn',
'userInterface': true,
'continue': true
}, res => {
console.log(res)
}, err => {
console.log(err)
});
错误信息:
{
"code": 2225220,
"message": "Error Domain=33 Code=2225220 \"asr authentication failed[info:-3004] [(-3004)] \" UserInfo={NSLocalizedDescription=asr authentication failed[info:-3004] [(-3004)] , NSHelpAnchor=CDC93E37-74A2-469A-9D5E-7D908562363E},https://ask.dcloud.net.cn/article/282"
}
乔小猿 (作者)
已临时解决,但这确实是个问题,解决方案如下:
如图,IOS端发现开通的时候必须勾选“实时语音识别”才可以,如果只勾选短语音,安卓可以,ios会报错。
这应该是uniapp内部针对ios端调用错了百度的接口!
该问题请在专业群( uni-app 官方技术交流群 1 ) 咨询,群中有相关专业的管理员和群友。
您好,根据您提供的错误信息 asr authentication failed[info:-3004],这是 百度语音识别 SDK 鉴权失败 的典型提示,不是框架 Bug,而是配置问题。
✅ 问题根因
iOS 端使用百度语音识别时,必须满足以下两个条件:
- manifest.json 中已正确配置百度语音的 AppID / APIKey / SecretKey;
- 配置的 Bundle Identifier 必须与百度控制台中填写的一致;
- 必须使用自定义基座运行(标准基座仅供体验,未包含您的鉴权信息)。
✅ 解决步骤(请按顺序操作)
1. 升级 HBuilderX
您当前使用的是 Alpha 版 4.87,建议立即升级至 正式版 4.87 或以上,避免旧版本潜在兼容问题。
2. 配置百度语音识别参数
打开 manifest.json → 在 “App模块配置” → “Speech(语音输入)” 中勾选 “百度语音识别”,并填写以下三项:
| 字段名 | 来源说明 |
|---|---|
| AppID | 百度语音开放平台申请的 AppID |
| APIKey | 百度语音开放平台申请的 API Key |
| SecretKey | 百度语音开放平台申请的 Secret Key |
? 请务必确认:百度控制台中填写的 Bundle ID 与您打包时使用的 iOS Bundle Identifier 完全一致。
3. 使用自定义基座运行
- 在 HBuilderX 中点击 【运行】→【运行到手机】→【制作自定义基座】;
- 制作完成后,选择 【使用自定义基座运行】;
- 每次修改 manifest.json 后,需重新制作自定义基座。
✅ 验证是否成功
完成上述步骤后,重新运行项目,调用如下代码:
plus.speech.startRecognize({
engine: 'baidu',
lang: 'zh-cn',
userInterface: true,
continue: true
}, res => {
console.log('识别成功:', res);
}, err => {
console.error('识别失败:', JSON.stringify(err));
});
❗ 如果仍然报错
请提供以下信息继续排查:
- manifest.json 中百度语音模块配置截图;
- 使用的是标准基座还是自定义基座;
- 百度控制台中填写的 Bundle ID 与打包时是否一致。
如需官方文档参考,请查看:配置百度语音识别

