百度语音唤醒踩坑合集
程序员文章站
2022-03-28 16:11:59
一、在语音识别中可以正常运行,唤醒也可以用,但是当判断是什么唤醒词语的时候出错?Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.W/System.err: org.json.JSONException: No value for appidat ....
一、在语音识别中可以正常运行,唤醒也可以用,但是当判断是什么唤醒词语的时候出错?
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
W/System.err: org.json.JSONException: No value for appid
at org.json.JSONObject.get(JSONObject.java:399)
at org.json.JSONObject.getInt(JSONObject.java:488)
at com.baidu.speech.asr.AnalysisInterceptor.send(Unknown Source:87)
at com.baidu.speech.asr.EventManagerWp.send(Unknown Source:47)
at vip.mtmy.helloworld.MainActivity.start(MainActivity.java:98)
at vip.mtmy.helloworld.MainActivity$1.onClick(MainActivity.java:58)
W/System.err: at android.view.View.performClick(View.java:7125)
W/System.err: at android.view.View.performClickInternal(View.java:7102)
W/System.err: at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27336)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
W/System.err: at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/MicrophoneServer: infile: audioSource:1
I/[BDASR_LOG] MicrophoneServer: add wrap socket, mRemoteOutputStreams size = 1 firstStart = true
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: vip.mtmy.helloworld, PID: 7280
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:121)
at org.json.JSONTokener.nextValue(JSONTokener.java:98)
at org.json.JSONObject.<init>(JSONObject.java:164)
at org.json.JSONObject.<init>(JSONObject.java:181)
at vip.mtmy.helloworld.MainActivity.onEvent(MainActivity.java:109)
at com.baidu.speech.asr.EventManagerWp$2$1.run(Unknown Source:56)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/[BDASR_LOG] audioSource :: 1
I/[BDASR_LOG] MicInputStream: startRecordingAndCheckStatus recorder status is 1
I/Process: Sending signal. PID: 7280 SIG: 9
解决方式:JSONObject jsonObject=new JSONObject(params);String word=jsonObject.getString(“word”);放到判断语句中即可解决
public void onEvent(String name, String params, byte[] data, int offset, int length) {
txtResult.setText(name);
try {
if ("wp.data".equals(name)) {
JSONObject jsonObject=new JSONObject(params);
String word=jsonObject.getString("word");
if (word.equals("陌途陌影")){
Toast.makeText(this, "唤醒成功啊", Toast.LENGTH_LONG).show();
}
// 识别相关的结果都在这里
Log.d("唤醒","唤醒成功");
}
else{
Toast.makeText(this,"唤醒失败",Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
本文地址:https://blog.csdn.net/qq_43691312/article/details/107590012
下一篇: CSP-游戏Python实现
推荐阅读
-
百度语音唤醒踩坑合集
-
Android 百度地图导航没有语音问题踩坑 重点是AndroidManifest.xml的配置问题
-
用WT516P6Core离线语音模块在烧录和连接MCU时要注意避开的坑,要不挠掉头发也钻不出来!我差点套进去了,还好他们技术人员给力!把我给扯出来了!做了一个踩坑记录分享给大家
-
Android studio百度地图开发 踩坑集锦1 Cause: duplicate entry: META-INF/MANIFEST.MF 真机调试安装包异常
-
安卓(Android)开发百度语音唤醒(识别)
-
Android学习笔记---集成百度语音合成的坑与坑
-
百度语音唤醒踩坑合集
-
用WT516P6Core离线语音模块在烧录和连接MCU时要注意避开的坑,要不挠掉头发也钻不出来!我差点套进去了,还好他们技术人员给力!把我给扯出来了!做了一个踩坑记录分享给大家