Android 语音唤醒 bad data source
176*****418 发布于2017-08 浏览:2359 回复:1
0
收藏

我使用的服务是:语音唤醒+离线语音识别

调用的接口是:

RecognitionListener

参数设置情况:

mWpEventManager = EventManagerFactory.create(MainActivity.this, "wp");

// 2) 注册唤醒事件监听器
mWpEventManager.registerListener(new EventListener() {
@Override
   public void onEvent(String name, String params, byte[] data, int offset, int length) {
Log.d("----robot", String.format("event: name=%s, params=%s", name, params));
       try {
JSONObject json = new JSONObject(params);
           if ("wp.data".equals(name)) { // 每次唤醒成功, 将会回调name=wp.data的时间, 被激活的唤醒词在params的word字段
               String word = json.getString("word");
               editText.append("唤醒成功, 唤醒词: " + word + "\r\n");
               setParam();

           } else if ("wp.exit".equals(name)) {
editText.append("唤醒已经停止: " + params + "\r\n");
           }
} catch (JSONException e) {
throw new AndroidRuntimeException(e);
       }
}
});

// 3) 通知唤醒管理器, 启动唤醒功能
HashMap params = new HashMap();
// 设置唤醒资源
params.put("kws-file", "assets:///WakeUp.bin");
mWpEventManager.send("wp.start", new JSONObject(params).toString(), null, 0, 0);

开发平台和机型:Android studio Android系统5.1.1

代码或日志截图(上传截图能帮助您更快解决问题):

 java.io.IOException: bad data source

08-24 14:05:53.148 13552-13552/? W/System.err:     at com.baidu.speech.EventContext.loadBytesFromUri(EventContext.java:103)

08-24 14:05:53.148 13552-13552/? W/System.err:     at com.baidu.speech.EventManagerWp.doWpStart(EventManagerWp.java:123)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.baidu.speech.EventManagerWp.send(EventManagerWp.java:57)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.baidu.speech.EventContext$SmartLogger$1.invoke(EventContext.java:288)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Proxy.invoke(Proxy.java:397)

08-24 14:05:53.149 13552-13552/? W/System.err:     at $Proxy0.send(Unknown Source)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.itgaozhen.gourdrebotdemo.MainActivity.onResume(MainActivity.java:87)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1257)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.Activity.performResume(Activity.java:6076)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2975)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3017)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.access$800(ActivityThread.java:151)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.os.Looper.loop(Looper.java:135)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5254)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

复现步骤、现象及其他描述:

唤醒功能打开就是 IOException bad data source

你们解决问题的效率真的太低了 加了群也不回答问题 还在疯狂拉人家进来是让我们自己讨论??


给你们个建议  android 版麻烦出个studio版的吧..这年头了谁还会用Eclipse

收藏
点赞
0
个赞
共1条回复 最后由用户已被禁言回复于2022-04
#2fujiayi1984回复于2017-08

176*****418:

我使用的服务是:语音唤醒+离线语音识别

调用的接口是:

RecognitionListener

参数设置情况:

mWpEventManager = EventManagerFactory.create(MainActivity.this, "wp");

// 2) 注册唤醒事件监听器
mWpEventManager.registerListener(new EventListener() {
@Override
   public void onEvent(String name, String params, byte[] data, int offset, int length) {
Log.d("----robot", String.format("event: name=%s, params=%s", name, params));
       try {
JSONObject json = new JSONObject(params);
           if ("wp.data".equals(name)) { // 每次唤醒成功, 将会回调name=wp.data的时间, 被激活的唤醒词在params的word字段
               String word = json.getString("word");
               editText.append("唤醒成功, 唤醒词: " + word + "\r\n");
               setParam();

           } else if ("wp.exit".equals(name)) {
editText.append("唤醒已经停止: " + params + "\r\n");
           }
} catch (JSONException e) {
throw new AndroidRuntimeException(e);
       }
}
});

// 3) 通知唤醒管理器, 启动唤醒功能
HashMap params = new HashMap();
// 设置唤醒资源
params.put("kws-file", "assets:///WakeUp.bin");
mWpEventManager.send("wp.start", new JSONObject(params).toString(), null, 0, 0);

开发平台和机型:Android studio Android系统5.1.1

代码或日志截图(上传截图能帮助您更快解决问题):

 java.io.IOException: bad data source

08-24 14:05:53.148 13552-13552/? W/System.err:     at com.baidu.speech.EventContext.loadBytesFromUri(EventContext.java:103)

08-24 14:05:53.148 13552-13552/? W/System.err:     at com.baidu.speech.EventManagerWp.doWpStart(EventManagerWp.java:123)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.baidu.speech.EventManagerWp.send(EventManagerWp.java:57)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.baidu.speech.EventContext$SmartLogger$1.invoke(EventContext.java:288)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Proxy.invoke(Proxy.java:397)

08-24 14:05:53.149 13552-13552/? W/System.err:     at $Proxy0.send(Unknown Source)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.itgaozhen.gourdrebotdemo.MainActivity.onResume(MainActivity.java:87)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1257)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.Activity.performResume(Activity.java:6076)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2975)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3017)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.access$800(ActivityThread.java:151)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.os.Looper.loop(Looper.java:135)

08-24 14:05:53.149 13552-13552/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5254)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)

08-24 14:05:53.149 13552-13552/? W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

08-24 14:05:53.149 13552-13552/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

复现步骤、现象及其他描述:

唤醒功能打开就是 IOException bad data source

你们解决问题的效率真的太低了 加了群也不回答问题 还在疯狂拉人家进来是让我们自己讨论??


给你们个建议  android 版麻烦出个studio版的吧..这年头了谁还会用Eclipse

回复176*****418:

 请测试下官方demo,可能是assets:///WakeUp.bin文件不存在

0
TOP
切换版块