BaseVoice

最低版本: 1.0.0最后更新: 2020/10/28

类说明:

分发 NLP 指令,使用责任链模式进行分发,如果要处理 nlp 指令,需要在 onListenCallback 中返回 true,否则会继续传递给下一个 voice 处理。

支持平台:

 

 

平台是否支持
豹小秘
豹大/花瓶
豹小秘 Mini

 

方法

方法名参数JS类型参数说明方法说明最低版本
onListenCallbackintentstringintent 指令 type分发语音指令1.0.0
resultany语音指令json 数据
idnumber语音请求 id
textstring语音文本内容

代码示例

export class BodyFollowVoice extends BaseVoice {
   private viewModel: BodyFollowViewModel;

   public constructor(viewModel: BodyFollowViewModel) {
       super(BodyFollowChannel);
       this.viewModel = viewModel;
   }

   public speak(): void {}

   public onListenCallback = (
       intent: string,
       result: any,
       id: number,
       text: string
   ): boolean => {
       console.log(TAG, 'onListenCallback', intent, result, id, text);
       switch (intent) {
           case IntentLocal.DO_NOT_MOVE:
               ActiveAbilityController.setBodyFollowEnable(false);
               return true;
       }
       return false;
   };
}