修改退出巡逻的语音指令
最后更新: 2019/7/5默认的巡逻员模板对用户发出的【取消】语音指令是不作处理的,现在我们将用户发出的【取消】语音指令处理为退出巡逻,实现机器人在收到【取消】的语音指令后退出巡逻任务。
按照目录app/template/cruise/CruiseVoice.ts打开CruiseVoice.ts
在CruiseVoice.ts中增加处理【取消】语音指令的数据:
case Intent.command_cancel:
添加完成后,用户即可使用【取消】的语音指令让机器人退出巡逻。
完成后的代码如下:
public onListenCallback = (
intent: string,
result: any,
id: any,
text: any
): boolean => {
switch (intent) {
case 'req_speech_wakeup':
this.viewModel._voiceTrigger(
FinishResult.RESULT_VOICE_WAKE_UP,
{ angle: result },
1
);
return true;
case Intent.command_stop:
case Intent.command_return:
return true;
case Intent.command_cancel:
case Intent.cruise_exit: {
this.viewModel.exitCruise(result);
break;
}
}
return true;
};
现在我们已经实现使用巡逻员模板,将机器人变为移动广告机器人,播放语音及图片广告资源。接下来我们将修改完成的代码打包,发布到机器人设备上。