BaseVoice
最低版本: 1.0.0最后更新: 2020/10/28类说明:
分发 NLP 指令,使用责任链模式进行分发,如果要处理 nlp 指令,需要在 onListenCallback 中返回 true,否则会继续传递给下一个 voice 处理。
支持平台:
平台 | 是否支持 |
豹小秘 | 是 |
豹大/花瓶 | 是 |
豹小秘 Mini | 是 |
方法
方法名 | 参数 | JS类型 | 参数说明 | 方法说明 | 最低版本 |
onListenCallback | intent | string | intent 指令 type | 分发语音指令 | 1.0.0 |
result | any | 语音指令json 数据 | |||
id | number | 语音请求 id | |||
text | string | 语音文本内容 |
代码示例
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;
};
}