|
smith tuo|
2020-6-12 10:12:21
|
显示全部楼层
回复少了一块东西,除了要配置trigger以外,还需要配置对应页面的voice,打开app/template/home/HomeVoice.ts,找到如下代码复制,并粘贴至对应的xxxVoice.ts文件中
- public onListenCallback = (
- intent: string,
- result: any,
- id: any,
- text: any
- ): boolean => {
- this.viewModel.resetTimeout();
- console.log('onListenCallback.......:' + String(intent));
- switch (intent) {
- case Intent.command_stop:
- this.viewModel._voiceTrigger(HomeEvent.stop, result);
- return true;
- case Intent.command_return:
- this.viewModel._voiceTrigger(HomeEvent.return, result);
- return true;
- // 跳转导览开始
- case 'MEUI&guide_introduction':
- this.viewModel._voiceTrigger(HomeEvent.guide, result);
- return true;
- // 跳转导览结束
- case 'register&ask':
- //通过下面json拿到姓名
- // GlobalVoiceTrigger: ', '{"channel":"","type":3,"result":{"answerTextPlay":true,"card":"{}","intent":"register®ister","queryType":2,"sid":"writing_40d36464-d84b-4360-b7d8-db8924a0d0d7","skillData":"{}","slots":"{\"start\":[{\"dict_name\":\"\",\"slot_type\":\"NORMAL\",\"text\":\"张三\",\"value\":\"张三\"}]}","soundAngle":-1,"userText":"我叫张三"},"eventId":-1}'
- let nameValue = result.value;
- RegisterUtils.getInstance().setRegisterAsk(true);
- return true;
- }
- return false;
- };
复制代码
PS: trigger配置页面跳转逻辑,voice配置页面语音识别返回结果处理,两者结合,可以实现指定语音结果业务处理逻辑 |
|