Intent intent = new Intent("com.baidu.action.RECOGNIZE_SPEECH");
//设置提示音
/* intent.putExtra(Constant.EXTRA_SOUND_START, R.raw.bdspeech_recognition_start);
intent.putExtra(Constant.EXTRA_SOUND_END, R.raw.bdspeech_speech_end);
intent.putExtra(Constant.EXTRA_SOUND_SUCCESS, R.raw.bdspeech_recognition_success);
intent.putExtra(Constant.EXTRA_SOUND_ERROR, R.raw.bdspeech_recognition_error);
intent.putExtra(Constant.EXTRA_SOUND_CANCEL, R.raw.bdspeech_recognition_cancel);*/
intent.putExtra(Constant.EXTRA_SAMPLE, "16000");//采样率
intent.putExtra(Constant.EXTRA_LANGUAGE, "cmn-Hans-CN");//语音
intent.putExtra(Constant.EXTRA_NLU, "enable");//语义解析
intent.putExtra(Constant.EXTRA_GRAMMAR, "assets://baidu_speech_grammar.bsg"); // 设置离线的授权文件(离线模块需要授权), 该语法可以用自定义语义工具生成, 链接http://yuyin.baidu.com/asr#m5
startActivityForResult(intent, 1);
//设置提示音
/* intent.putExtra(Constant.EXTRA_SOUND_START, R.raw.bdspeech_recognition_start);
intent.putExtra(Constant.EXTRA_SOUND_END, R.raw.bdspeech_speech_end);
intent.putExtra(Constant.EXTRA_SOUND_SUCCESS, R.raw.bdspeech_recognition_success);
intent.putExtra(Constant.EXTRA_SOUND_ERROR, R.raw.bdspeech_recognition_error);
intent.putExtra(Constant.EXTRA_SOUND_CANCEL, R.raw.bdspeech_recognition_cancel);*/
intent.putExtra(Constant.EXTRA_SAMPLE, "16000");//采样率
intent.putExtra(Constant.EXTRA_LANGUAGE, "cmn-Hans-CN");//语音
intent.putExtra(Constant.EXTRA_NLU, "enable");//语义解析
intent.putExtra(Constant.EXTRA_GRAMMAR, "assets://baidu_speech_grammar.bsg"); // 设置离线的授权文件(离线模块需要授权), 该语法可以用自定义语义工具生成, 链接http://yuyin.baidu.com/asr#m5
startActivityForResult(intent, 1);
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
您好,grammar的内容是什么呢,我们跟踪一下。另外可以将logcat的日志截取出来