From 099c71afc7cad3a47e48c770cd7b9bcf227cb4a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=96=87=E9=9D=99?= <1319697849@qq.com> Date: Tue, 13 May 2025 14:34:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=80=9D=E5=BF=85=E9=A9=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 514 +----------------- global/setting.go | 1 + main.go | 6 +- pkg/proto/alarm_remind_skill.pb.go | 687 ++++++++++++++++++++++++ pkg/proto/alarm_remind_skill.proto | 48 ++ pkg/proto/alarm_remind_skill_grpc.pb.go | 109 ++++ pkg/setting/section.go | 6 + service/connect/find_grpc.go | 13 +- service/speechNlu/constant.go | 1 + service/speechNlu/domain.go | 208 +++---- service/speechNlu/register.go | 1 + service/speechNlu/speech.go | 81 +-- service/speechNlu/speechWs.go | 163 +----- 13 files changed, 1013 insertions(+), 825 deletions(-) create mode 100644 pkg/proto/alarm_remind_skill.pb.go create mode 100644 pkg/proto/alarm_remind_skill.proto create mode 100644 pkg/proto/alarm_remind_skill_grpc.pb.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e9af88b..203ecb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,512 +1,4 @@ # 更新日志 -## [v1.1.47] - 2025年2月24日20:25:28 -### 新增 -* 新增 local ip. - -## [v1.1.46] - 2025年2月22日11:13:37 -### 新增 -* 新增 CGO_ENABLED=0 字段 - -## [v1.1.45] - 2025年2月21日15:56:07 -### 新增 -* 新增 log service 字段 - -## [v1.1.44-beta.1] - 2024年8月5日11:36:07 -### 新增 -* 新增 "gletkt_xlcj-1245258905417052160","ceshi-1149914105856290816","geliyoupingkongtiao-1289106967398617088","jhdpbxzswd-1364089899207012352","lxtest-1697504067777118921","lxtest-1697504245166677379","lchat-1736631343458063755" 的技能解析 - -## [v1.1.43-beta.28] - 2024年3月20日17:24:15 -### 变更 -* fm 细分码87654321 fm过滤m3u8 更改判断规则 - -## [v1.1.43-beta.27] - 2024年3月20日15:58:34 -### 变更 -* 腾讯切换正式环境 - -## [v1.1.43-beta.26] - 2024年3月20日10:47:31 -### 变更 -* 字段冲突 type更改为newsType - - -## [v1.1.43-beta.25] - 2024年3月4日16:44:11 -### 删除 -* 删除urltype判断逻辑 - -## [v1.1.43-beta.24] - 2024年3月4日15:57:55 -### 变更 -* appkey"a8814080829e11eda5c8e38bb1008e50" mid"10f05" 特殊处理同987654321设备一致 - -## [v1.1.43-beta.23] - 2024年3月4日15:15:19 -### 变更 -* appkey"a8814080829e11eda5c8e38bb1008e50" mid"10f05" 特殊处理同987654321设备一致 - -## [v1.1.43-beta.22] - 2024年2月1日17:17:05 -### 修复 -* 故事 title不存在则从selfData里找 - - -## [v1.1.43-beta.21] - 2024年1月24日15:11:11 -### 修复 -* 旧版 修复闹钟不同步的问题 - -## [v1.1.43-beta.20] - 2024年1月10日15:06:14 -### 变更 -* 旧版 屏蔽音乐的"search_prev_song"意图 - -## [v1.1.43-beta.19] - 2023年12月22日10:04:48 -### 变更 -* 旧版 更改baike获取回复语的方式 -### 新增 -* 流式 新增mchat的解析 - -## [v1.1.43-beta.18] - 2023年11月30日14:31:38 -### 新增 -* 增加对提醒native command指令的支持 - -## [v1.1.43-beta.17] - 2023年11月29日09:56:13 -### 新增 -* 新增homeId - -## [v1.1.43-beta.16] - 2023年11月28日10:39:22 -### 新增 -* tencentWs 接入闹钟提醒技能 -* 修复mid mac 未赋值的问题 - -## [v1.1.43-beta.15] - 2023年11月23日11:15:13 -### 变更 -* OtherDomainWs 的回复语策略 - -## [v1.1.43-beta.14] - 2023年11月23日10:24:06 -### 变更 -* OtherDomainWs 的回复语策略 - -## [v1.1.43-beta.13] - 2023年11月23日10:24:06 -### 变更 -* OtherDomainWs 的回复语策略 - -## [v1.1.43-beta.12] - 2023年11月22日14:22:55 -### 新增 -* 增加技能解析 - -## [v1.1.43-beta.11] - 2023年11月16日10:54:44 -### 新增 -* 增加注释 - -## [v1.1.43-beta.10] - 2023年11月10日09:45:08 -### 变更 -* 直播类型链接过滤逻辑增加mid midType限制 - -## [v1.1.43-beta.9] - 2023年11月8日10:21:15 -### 新增 -* 增加直播类型链接的过滤逻辑, 过滤后资源列表为空时返回回复语"小格没有找到相关的资源哦" - -## [v1.1.43-beta.8] - 2023年10月23日14:00:31 -### 新增 -* tencent wss 增加geography_kbqa general_question_answering htwhys_qa_pairs invention_qa_pairs 的解析 - -## [v1.1.43-beta.7] - 2023年10月23日14:00:31 -### 变更 -* tencent wss 增加language字段 - -## [v1.1.43-beta.6] - 2023年10月9日15:14:46 -### 变更 -* tencent wss 链接地址从consul env中获取 - -## [v1.1.43-beta.5] - 2023年10月9日14:05:08 -### 变更 -* tencent wss 链接地址从consul env中获取 - -## [v1.1.43-beta.4] - 2023年9月27日10:54:13 -### 新增 -* 新增 llm domain 的解析 - -## [v1.1.43-beta.3] - 2023年9月27日10:33:14 -### 删除 -* 去掉特殊处理(特殊处理部分设备切换到腾讯大语言模型bot) - -## [v1.1.43-beta.2] - 2023年9月27日09:58:38 -### 新增 -* 特殊处理部分设备切换到腾讯大语言模型bot - -## [v1.1.43-beta.1] - 2023年9月18日10:40:16 -### 新增 -* 腾讯流式接口 请求增加Location.City字段 -* 增加RewrittenQuery字段 - -## [v1.1.42-beta.2] - 2023年9月18日10:40:16 -### 修复 -* search_ancientpoem_meaning responseText转义字符引发json解析错误 - -## [v1.1.42-beta.1] - 2023年9月13日14:51:14 -### 修复 -* search_ancientpoem_meaning responseText转义字符引发json解析错误 - -## [v1.1.41-beta.4] - 2023年8月3日14:08:56 -### 修复 -* 修复鉴权服务挂掉时引发的错误 - -## [v1.1.41-beta.3] - 2023年7月27日17:18:03 -### 修复 -* 修复鉴权服务挂掉时引发的错误 -### 变更 -* dmsdk status为1时也获取dsn - -## [v1.1.41-beta.2] - 2023年7月27日11:03:12 -### 变更 -* 更改账号绑定\过期的提示话术 -* 完善log输出 - -## [v1.1.41-beta.1] - 2023年7月26日15:37:48 -### 变更 -* 取消globalCtrl下'确定' '取消' 的协议转换 - -## [v1.1.40-beta.40] - 2023年6月29日14:11:48 -### 变更 -* SessionComplete字段缺失问题 - -## [v1.1.40-beta.39] - 2023年6月25日10:59:37 -### 变更 -* 查询闹钟和提醒时, 内容过多就进行截断, 按照句子截断 - -## [v1.1.40-beta.38] - 2023年6月21日15:24:46 -### 变更 -* 优化 日志字段 - -## [v1.1.40-beta.37] - 2023年6月21日11:51:00 -### 新增 -* 增加 腾讯wss 的接入方式 -* 增加 流式grpc接口TencentNluParseStream -* 增加 日志字段 -* 增加 readme对查票接口的说明 - -## [v1.1.40-beta.36] - 2023年6月16日16:10:43 -### 变更 -* 解决weather回复语带有转义字符导致json解析失败的问题 -## [v1.1.40-beta.35] - 2023年6月16日11:28:26 -### 变更 -* 增加日志字段 -* 增加help domain的解析, 使用固定的回复 - -## [v1.1.40-beta.34] - 2023年6月12日15:33:00 -### 变更 -* 增加日志字段 - -## [v1.1.40-beta.33] - 2023年6月12日14:17:00 -### 变更 -* 增加日志字段 - -## [v1.1.40-beta.32] - 2023年6月12日13:36:44 -### 变更 -* 增加日志字段 - -## [v1.1.40-beta.31] - 2023年6月12日10:48:21 -### 变更 -* 增加日志字段 -* news 回复语修改 -* tencentV2 票据字段的校验及默认字段 - -## [v1.1.40-beta.30] - 2023年6月5日10:46:46 -### 变更 -* 从环境变量读取腾讯的配置信息 - -## [v1.1.40-beta.29] - 2023年5月17日09:22:17 -### 变更 -* 删除音乐资源扩充的代码逻辑 - -## [v1.1.40-beta.28] - 2023年5月11日09:36:58 -### 变更 -* 音乐资源扩充到30首, 分组排序方便终端测试 - -## [v1.1.40-beta.27] - 2023年5月10日13:51:52 -### 变更 -* 音乐资源扩充到20首用于测试 - -## [v1.1.40-beta.26] - 2023年5月10日10:37:31 -### 变更 -* 音乐资源扩充到30首用于测试 -* 增加音乐数目限制逻辑(mid非11011机型) - -## [v1.1.40-beta.25] - 2023年5月9日17:18:10 -### 变更 -* dmsdk status==0时 使用其返回的appkey accessToken - -## [v1.1.40-beta.24] - 2023年5月4日13:50:31 -### 变更 -* TokenSearch 使用增加mid vender字段查询dsn - -## [v1.1.40-beta.23] - 2023年4月27日15:36:54 -### 变更 -* 腾讯v2 增加世界之最的解析 -* 腾讯v2 古诗词鉴赏和意思, 拼接增加":" - - -## [v1.1.40-beta.22] - 2023年4月25日16:17:00 -### 变更 -* 腾讯v2 古诗domain中, 查询古诗含义, 查询古诗鉴赏, 拼接textContent 和 Text 进行返回 - -## [v1.1.40-beta.21] - 2023年4月24日13:59:24 -### 变更 -* 腾讯v2 增加mchat的解析 - -## [v1.1.40-beta.20] - 2023年4月19日11:16:51 -### 变更 -* 腾讯v2网关协议变更 auth字段放在http Header中 - -## [v1.1.40-beta.19] - 2023年4月14日11:27:34 -### 变更 -* 协议增加tRequestId字段 -* 腾讯v2 增加requestid参数 - -## [v1.1.40-beta.18] - 2023年4月10日13:58:07 -### 变更 -* 腾讯v2 增加globalctrl3技能的解析 - -## [v1.1.40-beta.17] - 2023年4月4日17:18:55 -### 变更 -* 腾讯v2 不再填充guid字段 - -## [v1.1.40-beta.16] - 2023年4月4日15:42:13 -### 新增 -* 新增guid字段 - -## [v1.1.40-beta.15] - 2023年3月28日15:04:41 -### 新增 -* tencentV2 screen_control volumectrl3 music -### 修复 -* tencentV2 guid的生成方式与旧接口的生成方式进行统一 - -## [v1.1.40-beta.14] - 2023年3月27日10:36:45 -### 修复 -* tencentV2 weather domain 的 text 校验 - -## [v1.1.40-beta.13] - 2023年3月27日10:03:54 -### 修复 -* tencentV2 weather domain 的 selfData 解析出错 - -## [v1.1.40-beta.12] - 2023年3月20日17:05:16 -### 新增 -* 增加鉴权信息字段, 腾讯v2 优先使用被传过来的鉴权信息 - -## [v1.1.40-beta.11] - 2023年3月17日09:06:01 -### 修复 -* 腾讯v2 newsdomain response_text 回复语过长, 替换成固定回复: "为你找到以下新闻:" - -## [v1.1.40-beta.10] - 2023年3月16日17:24:16 -### 修复 -* 删除resType 字段的获取 - -## [v1.1.40-beta.9] - 2023年3月16日11:48:10 -### 新增 -* 腾讯v2接口 新增 Command字段透传 - -## [v1.1.40-beta.8] - 2023年3月15日15:44:38 -### 新增 -* 腾讯v2接口 新增 default domain - -## [v1.1.40-beta.7] - 2023年3月15日15:24:10 -### 变更 -* 腾讯v2接口ip赋值更改为 Header X-Forwarded-For - -## [v1.1.40-beta.6] - 2023年3月15日14:37:59 -### 变更 -* 细分码存在非十进制数字的情况, 将 midType 重命名为vender, 相关的proto协议及数据库表进行更新 - -## [v1.1.40-beta.5] - 2023年3月13日10:43:56 -### 新增 -* 增加服务发现没有找到对应服务的校验机制 -### 变更 -* weather 删除mid限制 删除selfData的返回 -* chengyu 取消转为chat返回 - -## [v1.1.40-beta.4] - 2023年3月9日19:01:11 -### 新增 -* 模拟重定向 - -## [v1.1.40-beta.3] - 2023年3月3日08:49:51 -### 新增 -* 股票 星座 笑话 闲聊 体育 电台 古诗 新闻 节假日 - -## [v1.1.40-beta.2] - 2023年2月28日15:55:28 -### 变更 -* midAppKey 表增加midtype urltype字段, 读取进行兼容 -* 请求协议增加midtype字段 -* 增加新旧bot(接口)的访问逻辑, 指定的mid midtype(细分码)会访问新接口新bot -* 增加腾讯新接口的访问方式 -* 新接口 天气 和 闲聊 技能的解析逻辑 - -## [v1.1.40-beta] - 2023年1月15日11:02:59 -### 优化 -* grpc请求增加 grpc.WithNoProxy() - -## [v1.1.39] - 2023年1月12日11:08:53 -### 修复 -* 修复仅支持中英文翻译的判断逻辑 - -## [v1.1.38] - 2023年1月12日10:40:50 -### 优化 -* 变更consul服务信息获取方式 -* 不再兼容从dmsk获取dsn的http接口 - -## [v1.1.37] - 2023年1月12日09:56:24 -### 新增 -* 增加middleware中间件对panic捕获 - -## [v1.1.36] - 2022年11月18日17:37:12 -### 修复 -* replyWithChat() response_text中含有特殊字符(\n)导致的解析错误问题 -### 新增 -* 对翻译语言进行了限制(测试) - -## [v1.1.35] - 2022年10月28日10:23:16 -### 变更 -* newsDomain 取消replay_present不支持的回复语 - -## [v1.1.34] - 2022年10月21日11:14:33 -### 修复 -* poemDomain response_text中包含需转义的字符串导致json字符串无法加载的问题 - -## [v1.1.33] - 2022年10月14日14:19:37 -### 变更 -* poemDomain 对 "search_ancientpoem_meaning", "search_ancientpoem_appreciation", "search_ancientpoem_chains"意图 response_text进行拼接 - -## [v1.1.32] - 2022年9月14日19:17:35 -### 变更 -* poemDomain responst_text 为空时使用textContent - -## [v1.1.31] - 2022年9月13日14:40:58 -### 变更 -* dislike的协议转换变更为next - -## [v1.1.30] - 2022年9月5日09:31:12 -### 修复 -* fmDomain缺少mediaId -### 新增 -* music 增加playmore dislike的协议转换 -* poem 增加next的协议转换 -* fm 增加playmore next prev 的协议转换 - - -## [v1.1.29] - 2022年8月17日09:14:51 -### 优化 -* 优化consul client初始化方式 -### 新增 -* 增加对 globalctrl.turn_mid 协议转换 - -## [v1.1.28] - 2022年8月11日13:00:28 -### 优化 -* 优化通过consul获取host的方式 - -## [v1.1.27] - 2022年6月20日15:00:12 -### 优化 -* 天气技能 对内存不受限设备返回更多的天气数据 - -## [v1.0.15.1] - 2022年6月9日10:54:57 -### 新增 -- 天气技能 对无内存限制的设备返回更多的天气数据(vp柜机反馈缺少 温度,湿度,紫外线,七天天气数据,24小时温度数据) -### 说明 -- tag v1.0.15 对应CHANGELOG.md文档中的 v1.0.9 -- v1.0.15.1 表示在v1.0.15正式服版本基础上的修改 - -## [v1.1.26] - 2022年5月23日14:38:30 -### 新增 -* 天气技能 对有屏设备返回更多的天气数据(vp柜机反馈缺少 温度,湿度,紫外线,七天天气数据,24小时温度数据) -* config.yaml 配置文件 增加注释 - -## [v1.1.25] - 2022年5月23日10:17:48 -### 优化 -* 禅道 #64 对 music 下指定意图(pause pause_v2 next resume replay stop exit )进行协议转换 -* 禅道 #71 对 fm 下指定意图(change)进行支持, 对指定意图(pause exit stop)进行协议转换 - -## [v1.1.24] - 2022年4月28日10:13:28 -### 修复 -* 未能从dmsdk查票服务获取到Appkey AccessToken 时 通过mid去查AppKey AccessToken - -## [v1.1.23] - 2022年4月21日10:13:28 -### 修复 -* 更新docker file - -## [v1.1.22] - 2022年4月19日10:13:28 -### 修复 -* 更新docker file - -## [v1.1.21] - 2022年3月30日11:25:14 -### 新增 -* 请求叮当服务新增经纬度信息 - -## [v1.1.20] - 2022年3月25日15:26:40 -### 新增 -* 配置文件新增 11f06 10f05 相关的配置 -### 修复 -* 删除v1.1.18 "设备差异化的配置写死" 临时写死的逻辑 - -## [v1.1.19] - 2022年3月25日09:29:30 -### 修复 -* alarmDomain 返回字段格式问题 -* 优化consul实时获取服务消息 - -## [v1.1.18] - 2022年3月22日17:38:36 -### 新增 -* 设备差异化的配置写死 - -### 修复 -* 菜谱协议更改为listItems -* 优化http鉴权 - -## [v1.1.17] - 2022年3月4日15:11:00 -### 新增 -* dmsdk grpc服务不存在时则使用http接口获取鉴权dsn -* 实时从consul中获取服务信息 -* 增加grpc recover中间件 - -## [v1.1.16] - 2022年3月4日15:11:00 -### 修复 -* globalctrl 协议转换, 修复错误字段origin->orgin - -## [v1.1.15] - 2022年3月4日14:18:30 -### 修复 -* globalctrl 协议转换, turn_volume_to 分数 实体 转百分制数值 - -## [v1.1.10] - 时间 -### 新增 -* 接入grpc鉴权服务 - -### 修复 -* 超时采用闲聊兜底 - - -## [v1.0.10] - 2021年12月23日16:02:57 -### 新增 -* 增加"换一批歌曲"的解析 - -### 修复 -* 修复无资源列表返回时不使用服务定义的激活提示回复语 - -## [v1.0.9] - 2021年11月26日15:27:50 -### 新增 -* 从配置文件读取测试音频的链接 - -## [v1.0.8] - 2021年11月11日15:21:34 -### 修复 -* 增加"声道测试"音频资源 - -## [v1.0.7] - 2021年11月8日16:23:53 -### 修复 -* 修复jokeDomain 资源列表为空的时造成的错误 - -## [v1.0.6] - 2021年10月27日10:03:47 -### 修复 -* 增加music next 的返回数据的合法检测, 当腾讯解析返回错误数据时进行兜底回复 - -## [v1.0.5] - 2021年10月19日14:03:45 - -### 修复 -* 因腾讯问题返回jokeDomain资源列表为空时导致的数组越界问题 -* alarmDomain 增加对ret字段的判断,不等于0是不进行闹钟的插入 - -### 新增 -* mid 6400 及相应的appkey及token, 及相应的配置文件 -```sql -INSERT INTO chatroom.mid_appkey -(idmid_appkey, mid, appkey, access_token, mode, uri_type, created_at, updated_at, deleted_at) -VALUES(101, '6400', 'd636a7e02d8111eca6607b3e5760da03', 'f4765fb437d342e2b4bdcf774db81882', 0, 0, '2021-10-15 15:56:45', NULL, NULL); -``` +## [0.0.1-beta] - 2025.5.13 +### Changed +- 对接思必驰 diff --git a/global/setting.go b/global/setting.go index 367018f..36ccac5 100644 --- a/global/setting.go +++ b/global/setting.go @@ -20,4 +20,5 @@ var ( ServiceSetting *setting.ServiceSettingS ConsulObj *consul.ConsulObj TencentGwSetting *setting.TencentGwSetting + SpeechSetting *setting.SpeechSettings ) diff --git a/main.go b/main.go index 68b64b2..7ff4992 100644 --- a/main.go +++ b/main.go @@ -125,7 +125,7 @@ func setupFlag() error { flag.StringVar(&serverTag, "tag", "", "注册到注册中心的标签") flag.StringVar(&ip, "ip", "", "IP") flag.IntVar(&port, "port", 0, "端口") - flag.StringVar(&consulUrl, "consul", "http://172.28.124.105:8500", "consul服务地址") + flag.StringVar(&consulUrl, "consul", "http://172.28.124.106:8500", "consul服务地址") flag.StringVar(&config, "config", "env/v2,speech_nlu_parse/conf", "指定要使用的配置文件路径") flag.BoolVar(&isVersion, "version", false, "编译信息") flag.StringVar(&consulToken, "token", "092288b5-824f-854c-39aa-a958afd9a633", "consul token") @@ -191,6 +191,10 @@ func setupSetting() error { if err != nil { return err } + err = s.ReadSection("Speech", &global.SpeechSetting) + if err != nil { + return err + } consulUrlParse, err := url.Parse(consulUrl) if err != nil { diff --git a/pkg/proto/alarm_remind_skill.pb.go b/pkg/proto/alarm_remind_skill.pb.go new file mode 100644 index 0000000..7da21a8 --- /dev/null +++ b/pkg/proto/alarm_remind_skill.pb.go @@ -0,0 +1,687 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v4.25.1 +// source: pkg/proto/alarm_remind_skill.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AlarmRemindSkillRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AppInfo *AlarmRemindSkillRequest_AppInfo `protobuf:"bytes,1,opt,name=appInfo,proto3" json:"appInfo,omitempty"` + DevInfo *AlarmRemindSkillRequest_DevInfo `protobuf:"bytes,2,opt,name=devInfo,proto3" json:"devInfo,omitempty"` + UserInfo *AlarmRemindSkillRequest_UserInfo `protobuf:"bytes,3,opt,name=userInfo,proto3" json:"userInfo,omitempty"` + Command *AlarmRemindSkillRequest_Command `protobuf:"bytes,4,opt,name=command,proto3" json:"command,omitempty"` + AsrRecognize string `protobuf:"bytes,5,opt,name=asr_recognize,json=asrRecognize,proto3" json:"asr_recognize,omitempty"` +} + +func (x *AlarmRemindSkillRequest) Reset() { + *x = AlarmRemindSkillRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AlarmRemindSkillRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AlarmRemindSkillRequest) ProtoMessage() {} + +func (x *AlarmRemindSkillRequest) ProtoReflect() protoreflect.Message { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AlarmRemindSkillRequest.ProtoReflect.Descriptor instead. +func (*AlarmRemindSkillRequest) Descriptor() ([]byte, []int) { + return file_pkg_proto_alarm_remind_skill_proto_rawDescGZIP(), []int{0} +} + +func (x *AlarmRemindSkillRequest) GetAppInfo() *AlarmRemindSkillRequest_AppInfo { + if x != nil { + return x.AppInfo + } + return nil +} + +func (x *AlarmRemindSkillRequest) GetDevInfo() *AlarmRemindSkillRequest_DevInfo { + if x != nil { + return x.DevInfo + } + return nil +} + +func (x *AlarmRemindSkillRequest) GetUserInfo() *AlarmRemindSkillRequest_UserInfo { + if x != nil { + return x.UserInfo + } + return nil +} + +func (x *AlarmRemindSkillRequest) GetCommand() *AlarmRemindSkillRequest_Command { + if x != nil { + return x.Command + } + return nil +} + +func (x *AlarmRemindSkillRequest) GetAsrRecognize() string { + if x != nil { + return x.AsrRecognize + } + return "" +} + +type AlarmRemindSkillResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status *AlarmRemindSkillResponse_Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *AlarmRemindSkillResponse) Reset() { + *x = AlarmRemindSkillResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AlarmRemindSkillResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AlarmRemindSkillResponse) ProtoMessage() {} + +func (x *AlarmRemindSkillResponse) ProtoReflect() protoreflect.Message { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AlarmRemindSkillResponse.ProtoReflect.Descriptor instead. +func (*AlarmRemindSkillResponse) Descriptor() ([]byte, []int) { + return file_pkg_proto_alarm_remind_skill_proto_rawDescGZIP(), []int{1} +} + +func (x *AlarmRemindSkillResponse) GetStatus() *AlarmRemindSkillResponse_Status { + if x != nil { + return x.Status + } + return nil +} + +type AlarmRemindSkillRequest_AppInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AppId string `protobuf:"bytes,1,opt,name=appId,proto3" json:"appId,omitempty"` + RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *AlarmRemindSkillRequest_AppInfo) Reset() { + *x = AlarmRemindSkillRequest_AppInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AlarmRemindSkillRequest_AppInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AlarmRemindSkillRequest_AppInfo) ProtoMessage() {} + +func (x *AlarmRemindSkillRequest_AppInfo) ProtoReflect() protoreflect.Message { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AlarmRemindSkillRequest_AppInfo.ProtoReflect.Descriptor instead. +func (*AlarmRemindSkillRequest_AppInfo) Descriptor() ([]byte, []int) { + return file_pkg_proto_alarm_remind_skill_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *AlarmRemindSkillRequest_AppInfo) GetAppId() string { + if x != nil { + return x.AppId + } + return "" +} + +func (x *AlarmRemindSkillRequest_AppInfo) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type AlarmRemindSkillRequest_UserInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` + Hid string `protobuf:"bytes,2,opt,name=hid,proto3" json:"hid,omitempty"` +} + +func (x *AlarmRemindSkillRequest_UserInfo) Reset() { + *x = AlarmRemindSkillRequest_UserInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AlarmRemindSkillRequest_UserInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AlarmRemindSkillRequest_UserInfo) ProtoMessage() {} + +func (x *AlarmRemindSkillRequest_UserInfo) ProtoReflect() protoreflect.Message { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AlarmRemindSkillRequest_UserInfo.ProtoReflect.Descriptor instead. +func (*AlarmRemindSkillRequest_UserInfo) Descriptor() ([]byte, []int) { + return file_pkg_proto_alarm_remind_skill_proto_rawDescGZIP(), []int{0, 1} +} + +func (x *AlarmRemindSkillRequest_UserInfo) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *AlarmRemindSkillRequest_UserInfo) GetHid() string { + if x != nil { + return x.Hid + } + return "" +} + +type AlarmRemindSkillRequest_DevInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Mac string `protobuf:"bytes,1,opt,name=mac,proto3" json:"mac,omitempty"` + TarMac string `protobuf:"bytes,2,opt,name=tarMac,proto3" json:"tarMac,omitempty"` +} + +func (x *AlarmRemindSkillRequest_DevInfo) Reset() { + *x = AlarmRemindSkillRequest_DevInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AlarmRemindSkillRequest_DevInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AlarmRemindSkillRequest_DevInfo) ProtoMessage() {} + +func (x *AlarmRemindSkillRequest_DevInfo) ProtoReflect() protoreflect.Message { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AlarmRemindSkillRequest_DevInfo.ProtoReflect.Descriptor instead. +func (*AlarmRemindSkillRequest_DevInfo) Descriptor() ([]byte, []int) { + return file_pkg_proto_alarm_remind_skill_proto_rawDescGZIP(), []int{0, 2} +} + +func (x *AlarmRemindSkillRequest_DevInfo) GetMac() string { + if x != nil { + return x.Mac + } + return "" +} + +func (x *AlarmRemindSkillRequest_DevInfo) GetTarMac() string { + if x != nil { + return x.TarMac + } + return "" +} + +type AlarmRemindSkillRequest_Command struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Api string `protobuf:"bytes,1,opt,name=api,proto3" json:"api,omitempty"` + Repeat string `protobuf:"bytes,2,opt,name=repeat,proto3" json:"repeat,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Date string `protobuf:"bytes,4,opt,name=date,proto3" json:"date,omitempty"` + Time string `protobuf:"bytes,5,opt,name=time,proto3" json:"time,omitempty"` + Event string `protobuf:"bytes,6,opt,name=event,proto3" json:"event,omitempty"` + Period string `protobuf:"bytes,7,opt,name=period,proto3" json:"period,omitempty"` + Object string `protobuf:"bytes,8,opt,name=object,proto3" json:"object,omitempty"` // 区分品类,闹钟/日程(提醒) +} + +func (x *AlarmRemindSkillRequest_Command) Reset() { + *x = AlarmRemindSkillRequest_Command{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AlarmRemindSkillRequest_Command) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AlarmRemindSkillRequest_Command) ProtoMessage() {} + +func (x *AlarmRemindSkillRequest_Command) ProtoReflect() protoreflect.Message { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AlarmRemindSkillRequest_Command.ProtoReflect.Descriptor instead. +func (*AlarmRemindSkillRequest_Command) Descriptor() ([]byte, []int) { + return file_pkg_proto_alarm_remind_skill_proto_rawDescGZIP(), []int{0, 3} +} + +func (x *AlarmRemindSkillRequest_Command) GetApi() string { + if x != nil { + return x.Api + } + return "" +} + +func (x *AlarmRemindSkillRequest_Command) GetRepeat() string { + if x != nil { + return x.Repeat + } + return "" +} + +func (x *AlarmRemindSkillRequest_Command) GetTimestamp() int64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *AlarmRemindSkillRequest_Command) GetDate() string { + if x != nil { + return x.Date + } + return "" +} + +func (x *AlarmRemindSkillRequest_Command) GetTime() string { + if x != nil { + return x.Time + } + return "" +} + +func (x *AlarmRemindSkillRequest_Command) GetEvent() string { + if x != nil { + return x.Event + } + return "" +} + +func (x *AlarmRemindSkillRequest_Command) GetPeriod() string { + if x != nil { + return x.Period + } + return "" +} + +func (x *AlarmRemindSkillRequest_Command) GetObject() string { + if x != nil { + return x.Object + } + return "" +} + +type AlarmRemindSkillResponse_Status struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (x *AlarmRemindSkillResponse_Status) Reset() { + *x = AlarmRemindSkillResponse_Status{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AlarmRemindSkillResponse_Status) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AlarmRemindSkillResponse_Status) ProtoMessage() {} + +func (x *AlarmRemindSkillResponse_Status) ProtoReflect() protoreflect.Message { + mi := &file_pkg_proto_alarm_remind_skill_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AlarmRemindSkillResponse_Status.ProtoReflect.Descriptor instead. +func (*AlarmRemindSkillResponse_Status) Descriptor() ([]byte, []int) { + return file_pkg_proto_alarm_remind_skill_proto_rawDescGZIP(), []int{1, 0} +} + +func (x *AlarmRemindSkillResponse_Status) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *AlarmRemindSkillResponse_Status) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +var File_pkg_proto_alarm_remind_skill_proto protoreflect.FileDescriptor + +var file_pkg_proto_alarm_remind_skill_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x6c, 0x61, 0x72, + 0x6d, 0x5f, 0x72, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x5f, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaf, 0x05, 0x0a, 0x17, + 0x41, 0x6c, 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, 0x69, 0x6c, 0x6c, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x07, 0x61, 0x70, 0x70, 0x49, 0x6e, + 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x41, 0x6c, 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, 0x69, 0x6c, + 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x41, 0x70, 0x70, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x07, 0x61, 0x70, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, 0x0a, 0x07, 0x64, 0x65, 0x76, + 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, + 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, 0x65, 0x76, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x07, 0x64, 0x65, 0x76, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x43, 0x0a, 0x08, 0x75, + 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, + 0x64, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x40, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x61, 0x72, 0x6d, 0x52, + 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x73, 0x72, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x67, 0x6e, + 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x73, 0x72, 0x52, 0x65, + 0x63, 0x6f, 0x67, 0x6e, 0x69, 0x7a, 0x65, 0x1a, 0x3d, 0x0a, 0x07, 0x41, 0x70, 0x70, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x1a, 0x2e, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x75, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x68, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x68, 0x69, 0x64, 0x1a, 0x33, 0x0a, 0x07, 0x44, 0x65, 0x76, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x61, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6d, 0x61, 0x63, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x4d, 0x61, 0x63, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x4d, 0x61, 0x63, 0x1a, 0xbf, 0x01, 0x0a, 0x07, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x70, 0x69, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x70, 0x69, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x70, + 0x65, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x70, 0x65, 0x61, + 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, + 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, + 0x06, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, + 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x8a, 0x01, + 0x0a, 0x18, 0x41, 0x6c, 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, 0x69, + 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, + 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1a, 0x2e, 0x0a, 0x06, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0x6a, 0x0a, 0x10, 0x41, 0x6c, + 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x12, 0x56, + 0x0a, 0x13, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x53, 0x70, 0x65, 0x65, 0x63, 0x68, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, + 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, + 0x61, 0x72, 0x6d, 0x52, 0x65, 0x6d, 0x69, 0x6e, 0x64, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x13, 0x5a, 0x11, 0x2e, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_pkg_proto_alarm_remind_skill_proto_rawDescOnce sync.Once + file_pkg_proto_alarm_remind_skill_proto_rawDescData = file_pkg_proto_alarm_remind_skill_proto_rawDesc +) + +func file_pkg_proto_alarm_remind_skill_proto_rawDescGZIP() []byte { + file_pkg_proto_alarm_remind_skill_proto_rawDescOnce.Do(func() { + file_pkg_proto_alarm_remind_skill_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_proto_alarm_remind_skill_proto_rawDescData) + }) + return file_pkg_proto_alarm_remind_skill_proto_rawDescData +} + +var file_pkg_proto_alarm_remind_skill_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_pkg_proto_alarm_remind_skill_proto_goTypes = []interface{}{ + (*AlarmRemindSkillRequest)(nil), // 0: proto.AlarmRemindSkillRequest + (*AlarmRemindSkillResponse)(nil), // 1: proto.AlarmRemindSkillResponse + (*AlarmRemindSkillRequest_AppInfo)(nil), // 2: proto.AlarmRemindSkillRequest.AppInfo + (*AlarmRemindSkillRequest_UserInfo)(nil), // 3: proto.AlarmRemindSkillRequest.UserInfo + (*AlarmRemindSkillRequest_DevInfo)(nil), // 4: proto.AlarmRemindSkillRequest.DevInfo + (*AlarmRemindSkillRequest_Command)(nil), // 5: proto.AlarmRemindSkillRequest.Command + (*AlarmRemindSkillResponse_Status)(nil), // 6: proto.AlarmRemindSkillResponse.Status +} +var file_pkg_proto_alarm_remind_skill_proto_depIdxs = []int32{ + 2, // 0: proto.AlarmRemindSkillRequest.appInfo:type_name -> proto.AlarmRemindSkillRequest.AppInfo + 4, // 1: proto.AlarmRemindSkillRequest.devInfo:type_name -> proto.AlarmRemindSkillRequest.DevInfo + 3, // 2: proto.AlarmRemindSkillRequest.userInfo:type_name -> proto.AlarmRemindSkillRequest.UserInfo + 5, // 3: proto.AlarmRemindSkillRequest.command:type_name -> proto.AlarmRemindSkillRequest.Command + 6, // 4: proto.AlarmRemindSkillResponse.status:type_name -> proto.AlarmRemindSkillResponse.Status + 0, // 5: proto.AlarmRemindSkill.HandleSpeechCommand:input_type -> proto.AlarmRemindSkillRequest + 1, // 6: proto.AlarmRemindSkill.HandleSpeechCommand:output_type -> proto.AlarmRemindSkillResponse + 6, // [6:7] is the sub-list for method output_type + 5, // [5:6] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_pkg_proto_alarm_remind_skill_proto_init() } +func file_pkg_proto_alarm_remind_skill_proto_init() { + if File_pkg_proto_alarm_remind_skill_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pkg_proto_alarm_remind_skill_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AlarmRemindSkillRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_proto_alarm_remind_skill_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AlarmRemindSkillResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_proto_alarm_remind_skill_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AlarmRemindSkillRequest_AppInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_proto_alarm_remind_skill_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AlarmRemindSkillRequest_UserInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_proto_alarm_remind_skill_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AlarmRemindSkillRequest_DevInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_proto_alarm_remind_skill_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AlarmRemindSkillRequest_Command); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_proto_alarm_remind_skill_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AlarmRemindSkillResponse_Status); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pkg_proto_alarm_remind_skill_proto_rawDesc, + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_pkg_proto_alarm_remind_skill_proto_goTypes, + DependencyIndexes: file_pkg_proto_alarm_remind_skill_proto_depIdxs, + MessageInfos: file_pkg_proto_alarm_remind_skill_proto_msgTypes, + }.Build() + File_pkg_proto_alarm_remind_skill_proto = out.File + file_pkg_proto_alarm_remind_skill_proto_rawDesc = nil + file_pkg_proto_alarm_remind_skill_proto_goTypes = nil + file_pkg_proto_alarm_remind_skill_proto_depIdxs = nil +} diff --git a/pkg/proto/alarm_remind_skill.proto b/pkg/proto/alarm_remind_skill.proto new file mode 100644 index 0000000..ab55005 --- /dev/null +++ b/pkg/proto/alarm_remind_skill.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package proto; //新增一个可选的package声明符,用来防止不同的消息类型有命名冲突 +option go_package = "./pkg/proto;proto"; //这个选项表明生成go结构体所在的包 + + + +message AlarmRemindSkillRequest{ + message AppInfo { + string appId = 1; + string requestId = 2; + } + message UserInfo { + string uid = 1; + string hid = 2; + } + message DevInfo { + string mac = 1; + string tarMac = 2; + } + AppInfo appInfo = 1; + DevInfo devInfo = 2; + UserInfo userInfo = 3; + message Command { + string api = 1; + string repeat = 2; + int64 timestamp = 3; + string date = 4; + string time = 5; + string event = 6; + string period = 7; + string object = 8; // 区分品类,闹钟/日程(提醒) + } + Command command = 4; + string asr_recognize = 5; +} + +message AlarmRemindSkillResponse{ + message Status { + int32 code = 1; + string msg = 2; + } + Status status = 1; +} + +service AlarmRemindSkill { + rpc HandleSpeechCommand (AlarmRemindSkillRequest) returns (AlarmRemindSkillResponse); +} \ No newline at end of file diff --git a/pkg/proto/alarm_remind_skill_grpc.pb.go b/pkg/proto/alarm_remind_skill_grpc.pb.go new file mode 100644 index 0000000..ca026c3 --- /dev/null +++ b/pkg/proto/alarm_remind_skill_grpc.pb.go @@ -0,0 +1,109 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.1 +// source: pkg/proto/alarm_remind_skill.proto + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + AlarmRemindSkill_HandleSpeechCommand_FullMethodName = "/proto.AlarmRemindSkill/HandleSpeechCommand" +) + +// AlarmRemindSkillClient is the client API for AlarmRemindSkill service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AlarmRemindSkillClient interface { + HandleSpeechCommand(ctx context.Context, in *AlarmRemindSkillRequest, opts ...grpc.CallOption) (*AlarmRemindSkillResponse, error) +} + +type alarmRemindSkillClient struct { + cc grpc.ClientConnInterface +} + +func NewAlarmRemindSkillClient(cc grpc.ClientConnInterface) AlarmRemindSkillClient { + return &alarmRemindSkillClient{cc} +} + +func (c *alarmRemindSkillClient) HandleSpeechCommand(ctx context.Context, in *AlarmRemindSkillRequest, opts ...grpc.CallOption) (*AlarmRemindSkillResponse, error) { + out := new(AlarmRemindSkillResponse) + err := c.cc.Invoke(ctx, AlarmRemindSkill_HandleSpeechCommand_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AlarmRemindSkillServer is the server API for AlarmRemindSkill service. +// All implementations must embed UnimplementedAlarmRemindSkillServer +// for forward compatibility +type AlarmRemindSkillServer interface { + HandleSpeechCommand(context.Context, *AlarmRemindSkillRequest) (*AlarmRemindSkillResponse, error) + mustEmbedUnimplementedAlarmRemindSkillServer() +} + +// UnimplementedAlarmRemindSkillServer must be embedded to have forward compatible implementations. +type UnimplementedAlarmRemindSkillServer struct { +} + +func (UnimplementedAlarmRemindSkillServer) HandleSpeechCommand(context.Context, *AlarmRemindSkillRequest) (*AlarmRemindSkillResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HandleSpeechCommand not implemented") +} +func (UnimplementedAlarmRemindSkillServer) mustEmbedUnimplementedAlarmRemindSkillServer() {} + +// UnsafeAlarmRemindSkillServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AlarmRemindSkillServer will +// result in compilation errors. +type UnsafeAlarmRemindSkillServer interface { + mustEmbedUnimplementedAlarmRemindSkillServer() +} + +func RegisterAlarmRemindSkillServer(s grpc.ServiceRegistrar, srv AlarmRemindSkillServer) { + s.RegisterService(&AlarmRemindSkill_ServiceDesc, srv) +} + +func _AlarmRemindSkill_HandleSpeechCommand_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AlarmRemindSkillRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AlarmRemindSkillServer).HandleSpeechCommand(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AlarmRemindSkill_HandleSpeechCommand_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AlarmRemindSkillServer).HandleSpeechCommand(ctx, req.(*AlarmRemindSkillRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// AlarmRemindSkill_ServiceDesc is the grpc.ServiceDesc for AlarmRemindSkill service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AlarmRemindSkill_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.AlarmRemindSkill", + HandlerType: (*AlarmRemindSkillServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "HandleSpeechCommand", + Handler: _AlarmRemindSkill_HandleSpeechCommand_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "pkg/proto/alarm_remind_skill.proto", +} diff --git a/pkg/setting/section.go b/pkg/setting/section.go index c5561c3..8e61248 100644 --- a/pkg/setting/section.go +++ b/pkg/setting/section.go @@ -90,6 +90,12 @@ type TencentGwSetting struct { } } +type SpeechSettings struct { + ProductId string + ApiKey string + Url string +} + func (s *Setting) ReadSection(k string, v interface{}) error { return s.vp.UnmarshalKey(k, v) } diff --git a/service/connect/find_grpc.go b/service/connect/find_grpc.go index 07fc71c..ee08e9f 100644 --- a/service/connect/find_grpc.go +++ b/service/connect/find_grpc.go @@ -28,16 +28,22 @@ func GrpcConn(serverName string) (*grpc.ClientConn, error) { // 通过 Consul 客户端查询服务实例 consulConfig := api.DefaultConfig() consulConfig.Address = global.ServerSetting.ConsulAddr - client, _ := api.NewClient(consulConfig) + client, err := api.NewClient(consulConfig) + if err != nil { + return nil, fmt.Errorf("consul client init failed: %v", err) + } entries, _, _ := client.Health().Service(serverName, "", true, nil) + // 健康实例检查 + if len(entries) == 0 { + return nil, fmt.Errorf("no available instances for service [%s]", serverName) + } + // 获取第一个健康实例的地址 targetAddr := fmt.Sprintf("%s:%d", entries[0].Service.Address, entries[0].Service.Port) - //target := fmt.Sprintf("consul://%s/%s", global.ConsulAddr, serverName) - //fmt.Println("1111123132131312") fmt.Println(targetAddr) opts := []grpc.DialOption{ //grpc.WithBlock(), //阻塞连接直到成功或超时,存在缺陷 @@ -45,7 +51,6 @@ func GrpcConn(serverName string) (*grpc.ClientConn, error) { grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)), // 设置默认的负载均衡策略 } - var err error conn, err := grpc.DialContext(ctx, targetAddr, opts...) if err != nil { return nil, err diff --git a/service/speechNlu/constant.go b/service/speechNlu/constant.go index f8e911c..3e1ac9b 100644 --- a/service/speechNlu/constant.go +++ b/service/speechNlu/constant.go @@ -84,6 +84,7 @@ const ( PlayCTRL = "播放控制" MUSIC = "音乐" HELP = "产品形象" + STORY = "故事" HOLIDAY = "holiday" SOUND = "sound" diff --git a/service/speechNlu/domain.go b/service/speechNlu/domain.go index 81abfa1..7939431 100644 --- a/service/speechNlu/domain.go +++ b/service/speechNlu/domain.go @@ -5,14 +5,12 @@ import ( "errors" "fmt" "regexp" - "speech-nlu-parse/dao" "speech-nlu-parse/global" "speech-nlu-parse/model" "speech-nlu-parse/pkg/logger" "speech-nlu-parse/service/connect" "strconv" "strings" - "time" ) const ( @@ -330,105 +328,107 @@ type AlarmItem struct { // 闹钟待写 func alarmDomain(params *model.SpeechDomainParams) []byte { - mac := params.Mac - - if !params.CheckDm() || !params.CheckDmParam() { - return replyWithChat(error_reply, "doudi") - } - - var result model.ResponseBody - result.Header.Semantic.Code = 0 - result.Header.Semantic.Msg = speech_nlu_parse - result.Header.Semantic.SessionComplete = params.SpeechWsResp.Dm.ShouldEndSession + //mac := params.Mac + // + //if !params.CheckDm() || !params.CheckDmParam() { + // return replyWithChat(error_reply, "doudi") + //} + // + //var result model.ResponseBody + //result.Header.Semantic.Code = 0 + //result.Header.Semantic.Msg = speech_nlu_parse + //result.Header.Semantic.SessionComplete = params.SpeechWsResp.Dm.ShouldEndSession + ////result.Header.Semantic.SkillId = result.Header.Semantic.Domain + "." + result.Header.Semantic.Intent + //result.AsrRecongize = params.SpeechWsResp.Dm.Input + // + //var alarmDBData model.AlarmRemindInfo + //alarmDBData.Mac = params.Mac + //alarmDBData.Note = "" + //alarmDBData.URL = "" + //alarmDBData.Speech_Type = onlyTTS + //alarmDBData.Createtime = time.Now().String()[:19] + ////items := "" + //contentTTS := "" + // + //if params.SpeechWsResp.Dm.Param.Object == "闹钟" { + // alarmDBData.E_type = alarm + // result.Header.Semantic.Domain = "alarm" + //} else { + // alarmDBData.E_type = remind + // result.Header.Semantic.Domain = "reminder_v2" + // if !params.CheckEvent() { + // contentTTS = alarm_remind_common + params.SpeechWsResp.Dm.Param.Event + // } else { + // contentTTS = alarm_remind_raw + // } + // alarmDBData.Note = contentTTS + //} + //fmt.Println(contentTTS) + // + //if params.SpeechWsResp.Dm.Api == "DUI.Alerts.SetAlert" { + // result.Header.Semantic.Intent = "new" + // if !params.CheckDate() { + // global.Logger.WithFields(logger.Fields{ + // "requestId": params.RequestId, + // "mac": params.Mac, + // "mid": params.Mid, + // "vender": params.MidType}).Error("params.CheckDate() error") + // return replyWithChat(error_reply, "doudi") + // } else { + // //如果日期存在 + // t, err := time.Parse("20060102", params.SpeechWsResp.Dm.Param.Date) + // if err != nil { + // global.Logger.WithFields(logger.Fields{ + // "requestId": params.RequestId, + // "mac": params.Mac, + // "mid": params.Mid, + // "vender": params.MidType}).Error(err.Error()) + // return replyWithChat(error_reply, "doudi") + // } + // + // // 将日期转换为目标格式 + // formatted := t.Format("2006-01-02") + // alarmDBData.E_date = formatted + // //获得时间 + // alarmDBData.E_time = params.SpeechWsResp.Dm.Param.Time + // } + // + // if !params.CheckRepeat() { + // alarmDBData.Repeat_type = 1 + // } else if params.SpeechWsResp.Dm.Param.Repeat == "W1W2W3W4W5W6W7" { + // alarmDBData.Repeat_type = 2 + // } else if params.SpeechWsResp.Dm.Param.Repeat == "W1W2W3W4W5" { + // alarmDBData.Repeat_type = 5 + // } else if strings.Contains(strings.ToLower(params.SpeechWsResp.Dm.Param.Repeat), "M") { + // alarmDBData.Repeat_type = 4 + // } else if strings.Contains(strings.ToLower(params.SpeechWsResp.Dm.Param.Repeat), "W") { + // alarmDBData.Repeat_type = 3 + // //每周几待写 + // } + // dao.SaveAlarmRemindData(alarmDBData) + // if params.SpeechWsResp.Dm.Nlg != "" { + // result.ResponseText = params.SpeechWsResp.Dm.Nlg + // } else { + // result.ResponseText = "已经设置好了" + // } + // + //} else if params.SpeechWsResp.Dm.Api == "DUI.Alerts.QueryAlert" { + // result.Header.Semantic.Intent = "check" + // dao.DeleteOverdueAlarmRemindData(mac) + // + //} else if params.SpeechWsResp.Dm.Api == "DUI.Alerts.DeleteAlert" { + // result.Header.Semantic.Intent = "delete" + //} + // //result.Header.Semantic.SkillId = result.Header.Semantic.Domain + "." + result.Header.Semantic.Intent - result.AsrRecongize = params.SpeechWsResp.Dm.Input - - var alarmDBData model.AlarmRemindInfo - alarmDBData.Mac = params.Mac - alarmDBData.Note = "" - alarmDBData.URL = "" - alarmDBData.Speech_Type = onlyTTS - alarmDBData.Createtime = time.Now().String()[:19] - //items := "" - contentTTS := "" - - if params.SpeechWsResp.Dm.Param.Object == "闹钟" { - alarmDBData.E_type = alarm - result.Header.Semantic.Domain = "alarm" - } else { - alarmDBData.E_type = remind - result.Header.Semantic.Domain = "reminder_v2" - if !params.CheckEvent() { - contentTTS = alarm_remind_common + params.SpeechWsResp.Dm.Param.Event - } else { - contentTTS = alarm_remind_raw - } - alarmDBData.Note = contentTTS - } - fmt.Println(contentTTS) - - if params.SpeechWsResp.Dm.Api == "DUI.Alerts.SetAlert" { - result.Header.Semantic.Intent = "new" - if !params.CheckDate() { - global.Logger.WithFields(logger.Fields{ - "requestId": params.RequestId, - "mac": params.Mac, - "mid": params.Mid, - "vender": params.MidType}).Error("params.CheckDate() error") - return replyWithChat(error_reply, "doudi") - } else { - //如果日期存在 - t, err := time.Parse("20060102", params.SpeechWsResp.Dm.Param.Date) - if err != nil { - global.Logger.WithFields(logger.Fields{ - "requestId": params.RequestId, - "mac": params.Mac, - "mid": params.Mid, - "vender": params.MidType}).Error(err.Error()) - return replyWithChat(error_reply, "doudi") - } - - // 将日期转换为目标格式 - formatted := t.Format("2006-01-02") - alarmDBData.E_date = formatted - //获得时间 - alarmDBData.E_time = params.SpeechWsResp.Dm.Param.Time - } - - if !params.CheckRepeat() { - alarmDBData.Repeat_type = 1 - } else if params.SpeechWsResp.Dm.Param.Repeat == "W1W2W3W4W5W6W7" { - alarmDBData.Repeat_type = 2 - } else if params.SpeechWsResp.Dm.Param.Repeat == "W1W2W3W4W5" { - alarmDBData.Repeat_type = 5 - } else if strings.Contains(strings.ToLower(params.SpeechWsResp.Dm.Param.Repeat), "M") { - alarmDBData.Repeat_type = 4 - } else if strings.Contains(strings.ToLower(params.SpeechWsResp.Dm.Param.Repeat), "W") { - alarmDBData.Repeat_type = 3 - //每周几待写 - } - dao.SaveAlarmRemindData(alarmDBData) - if params.SpeechWsResp.Dm.Nlg != "" { - result.ResponseText = params.SpeechWsResp.Dm.Nlg - } else { - result.ResponseText = "已经设置好了" - } - - } else if params.SpeechWsResp.Dm.Api == "DUI.Alerts.QueryAlert" { - result.Header.Semantic.Intent = "check" - dao.DeleteOverdueAlarmRemindData(mac) - - } else if params.SpeechWsResp.Dm.Api == "DUI.Alerts.DeleteAlert" { - result.Header.Semantic.Intent = "delete" - } - - result.Header.Semantic.SkillId = result.Header.Semantic.Domain + "." + result.Header.Semantic.Intent - - if !alarmDevFilter(params) { - return Marshal(params, &result) - } - - return Marshal(params, &result) + // + //if !alarmDevFilter(params) { + // return Marshal(params, &result) + //} + // + //return Marshal(params, &result) + resultTextStr := "暂不支持闹钟设定" + return replyWithChat(resultTextStr, "chat.chat") } func scienceDomain(params *model.SpeechDomainParams) []byte { @@ -512,6 +512,9 @@ func fmDomain(params *model.SpeechDomainParams) []byte { "mid": params.Mid, "vender": params.MidType, }).Error("params.SpeechWsResp.Dm.Widget.Content不是数组类型") + if res.ResponseText != "" { + return replyWithChat(res.ResponseText, "doudi") + } return replyWithChat(error_reply, "doudi") } @@ -667,7 +670,7 @@ func musicDomain(params *model.SpeechDomainParams) []byte { result.Header.Semantic.Msg = speech_nlu_parse result.Header.Semantic.SessionComplete = params.SpeechWsResp.Dm.ShouldEndSession result.Header.Semantic.SkillId = result.Header.Semantic.Domain + "." + result.Header.Semantic.Intent - result.ResponseText = params.SpeechWsResp.Dm.Nlg + //result.ResponseText = "以下音乐由网易云提供:" //params.SpeechWsResp.Dm.Nlg result.AsrRecongize = params.SpeechWsResp.Dm.Input result.ListItems = make([]map[string]interface{}, 0) if len(list.Data.ListItems) > 0 { @@ -678,6 +681,9 @@ func musicDomain(params *model.SpeechDomainParams) []byte { "song": list.Data.ListItems[i].Song, }) } + result.ResponseText = "以下音乐由网易云提供:" //params.SpeechWsResp.Dm.Nlg + } else { + return otherDomain(params) } return Marshal(params, &result) } diff --git a/service/speechNlu/register.go b/service/speechNlu/register.go index 2808640..d185f10 100644 --- a/service/speechNlu/register.go +++ b/service/speechNlu/register.go @@ -44,6 +44,7 @@ func register() { DomainRegister(PlayCTRL, playCtrlDomain) DomainRegister(MUSIC, musicDomain) DomainRegister(HELP, helpDomain) + DomainRegister(STORY, fmDomain) // //DomainRegisterV2(CHAT, chatDomainV2) diff --git a/service/speechNlu/speech.go b/service/speechNlu/speech.go index 263802f..190ff4f 100644 --- a/service/speechNlu/speech.go +++ b/service/speechNlu/speech.go @@ -8,6 +8,7 @@ import ( "speech-nlu-parse/global" "speech-nlu-parse/model" "speech-nlu-parse/pkg/errCode" + "speech-nlu-parse/pkg/logger" "sync" "time" ) @@ -49,8 +50,6 @@ func SpeechNlu(reqStruct *model.SemanticReq) (string, *errCode.Error) { } else if reqStruct.Query == "编号七零六八一" && reqStruct.MacWifi == "f4911e594443" { channelStr = string(getGreeNluChatReply("好的,计时五分钟马上开始,五,四,三,二,一", "countdown", reqStruct.Query)) } else { - fmt.Println("---------------------待解析---------------------") - data := SpeechNlpWsReq(reqStruct) speechNluWs := SpeechNlpWs{} @@ -58,7 +57,10 @@ func SpeechNlu(reqStruct *model.SemanticReq) (string, *errCode.Error) { nlpWsConn, err = speechNluWs.SpeechWs() if err != nil { - global.Logger.Errorf("speechWs.SpeechWs error. %v", err) + global.Logger.WithFields(logger.Fields{ + "requestId": reqStruct.RequestId, + "reqStruct": reqStruct, + }).Errorf("speechNluWs.SpeechWs error: %v", err) return string(replyWithChat(error_reply, "doudi")), errCode.InternalServiceError } speechNluWs.NlpWsConn = nlpWsConn @@ -70,7 +72,10 @@ func SpeechNlu(reqStruct *model.SemanticReq) (string, *errCode.Error) { go receiveMessage(nlpWsConn, done, dataChan) if err := sendRunTaskMsg(nlpWsConn, data); err != nil { - fmt.Println("发送run-task指令失败:", err) + global.Logger.WithFields(logger.Fields{ + "requestId": reqStruct.RequestId, + "reqStruct": reqStruct, + }).Errorf("发送run-task指令失败:%v", err) return string(replyWithChat(error_reply, "doudi")), errCode.InternalServiceError } @@ -78,23 +83,25 @@ func SpeechNlu(reqStruct *model.SemanticReq) (string, *errCode.Error) { select { case <-done: responses = <-dataChan - fmt.Println("任务成功完成,接收数据如下:") - for _, resp := range responses { - semanticRespByteData := ParseSpeechJson(resp, reqStruct.MacWifi, reqStruct.OriginQuery, reqStruct.Mid) + semanticRespByteData := ParseSpeechJson(resp, reqStruct.MacWifi, reqStruct.OriginQuery, reqStruct.Mid, reqStruct.RequestId, + reqStruct.Vender) return string(semanticRespByteData), errCode.Success - //fmt.Printf("%+v\n", resp) } case <-time.After(5 * time.Minute): - fmt.Println("任务超时,尝试获取已接收数据...") select { case responses = <-dataChan: - fmt.Println("部分接收数据如下:") for _, resp := range responses { fmt.Printf("%+v\n", resp) + semanticRespByteData := ParseSpeechJson(resp, reqStruct.MacWifi, reqStruct.OriginQuery, reqStruct.Mid, reqStruct.RequestId, + reqStruct.Vender) + return string(semanticRespByteData), errCode.Success } default: - fmt.Println("未接收到任何数据") + global.Logger.WithFields(logger.Fields{ + "requestId": reqStruct.RequestId, + "reqStruct": reqStruct, + }).Error("未接收到任何数据") return string(replyWithChat(error_reply, "doudi")), errCode.InternalServiceError } } @@ -124,20 +131,18 @@ func receiveMessage(conn *websocket.Conn, done chan struct{}, dataChan chan<- [] for { _, message, err := conn.ReadMessage() if err != nil { - fmt.Println("\n消息接收终止:", err) + global.Logger.Errorf("消息接收终止:%v", err) return } //思必驰nlu回复 - fmt.Println("原始消息") - fmt.Println(string(message)) - var resp model.SpeechWsResp if err := json.Unmarshal(message, &resp); err != nil { - fmt.Println("消息解析失败:", err) + global.Logger.WithFields(logger.Fields{ + "origin-data": string(message), + }).Errorf("json.Unmarshal error:%v", err) continue } - fmt.Printf("\n收到新消息:%+v\n", string(message)) responses = append(responses, resp) //resp.Dm.ShouldEndSession不能判定是否结束 @@ -148,41 +153,10 @@ func receiveMessage(conn *websocket.Conn, done chan struct{}, dataChan chan<- [] if resp.Dm != nil { return } - - //r := resp.SpeechWsResponse(p.RequestId) - // - //if resp.Topic == "tts.error" { - // global.Logger.WithFields(logger.Fields{ - // "RequestId": p.RequestId, - // "Code": resp.Error.ErrId, - // "Message": resp.Error.Error, - // "Time": time.Since(st), - // "SpeechWsRequestId": resp.RecordId, - // }).Error("[SpeechWs] 返回message错误") - // r.Status.Code = int32(YXWConvertErrorCode(YXWRespCode(r.Status.Code))) - // p.Send(r) - // return - //} - //p.Send(r) - // - //fmt.Println("1111111") - //fmt.Println(resp) - // - //if resp.Topic == "tts.stream.end" { - // global.Logger.WithFields(logger.Fields{ - // "RequestId": p.RequestId, - // "Topic": resp.Topic, - // "Time": time.Since(st).Seconds(), - // "SpeechWsRequestId": resp.RecordId, - // }).Info("[SpeechWs] 读取结束") - // - // close(audioChan) - // break - //} } } -func ParseSpeechJson(speechJson model.SpeechWsResp, mac string, query, mid string) []byte { +func ParseSpeechJson(speechJson model.SpeechWsResp, mac string, query, mid, requestId, vender string) []byte { //思必驰返回的domain是中文,待改 domain := speechJson.Skill @@ -192,14 +166,11 @@ func ParseSpeechJson(speechJson model.SpeechWsResp, mac string, query, mid strin params := &model.SpeechDomainParams{ SpeechWsResp: &speechJson, Query: query, - RequestId: "", + RequestId: requestId, Mac: mac, Domain: domain, Mid: mid, - MidType: "", - SessionId: "", - HomeId: "", - AppKey: "", + MidType: vender, } // 根据mid屏蔽部分domain, 并返回 @@ -210,8 +181,6 @@ func ParseSpeechJson(speechJson model.SpeechWsResp, mac string, query, mid strin //jsonByte = jokeDomain(speechJson) - fmt.Println("domain:", domain) - if value, ok := getHandler(domain); ok { jsonByte = value(params) } else { diff --git a/service/speechNlu/speechWs.go b/service/speechNlu/speechWs.go index 39e9a06..8ba9a4a 100644 --- a/service/speechNlu/speechWs.go +++ b/service/speechNlu/speechWs.go @@ -18,10 +18,10 @@ type SpeechNlpWs struct { mutex sync.Mutex } -func (this *SpeechNlpWs) SpeechWs() (*websocket.Conn, error) { - SpeechWs_Url := "wss://dds.dui.ai/dds/v2/test" - SpeechWs_ProductId := "279629895" - SpeechWs_ApiKey := "0c74988953dd4ed4bf31955527802cf3" +func (s *SpeechNlpWs) SpeechWs() (*websocket.Conn, error) { + SpeechWs_Url := global.SpeechSetting.Url + SpeechWs_ProductId := global.SpeechSetting.ProductId + SpeechWs_ApiKey := global.SpeechSetting.ApiKey //st := time.Now() dialer := websocket.Dialer{ @@ -40,19 +40,18 @@ func (this *SpeechNlpWs) SpeechWs() (*websocket.Conn, error) { //"RequestId": p.RequestId, "resp": readResp(resp), }).Errorf("[SpeechWs] Connect error : %v", err.Error()) - //p.Send(ErrorResponse(CodeConnectError, "connect speechWs error")) return nil, err } return conn, nil } -func (this *SpeechNlpWs) Send(data interface{}) error { - this.NlpWsConn.WriteJSON(data) +func (s *SpeechNlpWs) Send(data interface{}) error { + s.NlpWsConn.WriteJSON(data) return nil } -func (this *SpeechNlpWs) Recv() ([]byte, error) { - _, msg, err := this.NlpWsConn.ReadMessage() +func (s *SpeechNlpWs) Recv() ([]byte, error) { + _, msg, err := s.NlpWsConn.ReadMessage() return msg, err } @@ -76,7 +75,7 @@ func SpeechNlpWsReq(data *model.SemanticReq) *SpeechWsData { return req } -func (this *SpeechNlpWs) ParseSpeechNluData(jsonData []byte, requestId, sessionId string) []byte { +func (s *SpeechNlpWs) ParseSpeechNluData(jsonData []byte, requestId, sessionId string) []byte { speechNlpWsResp := model.SpeechWsResp{} err := json.Unmarshal(jsonData, &speechNlpWsResp) if err != nil { @@ -94,153 +93,13 @@ func (this *SpeechNlpWs) ParseSpeechNluData(jsonData []byte, requestId, sessionI return jsonData } -func (this *SpeechNlpWs) WsSend(body *SpeechWsData) { - this.Send(body) +func (s *SpeechNlpWs) WsSend(body *SpeechWsData) { + s.Send(body) } -//type SpeechWsConnection struct { -// conn *websocket.Conn -// mutex sync.Mutex -//} -// -//var SpeechWg = &sync.WaitGroup{} - type SpeechWsData struct { Topic string `json:"topic"` // 必选 RecordId string `json:"recordId"` // 可选,uuid,请求标识 SessionId string `json:"sessionId"` // 可选,首轮不带此参数,非首轮必须带此参数 RefText string `json:"refText"` // 必选,请求文本 } - -//func SpeechWs(data model.SemanticReq) { -// da := SpeechNlpWsReq(data) -// -// st := time.Now() -// dialer := websocket.Dialer{ -// HandshakeTimeout: 30 * time.Second, -// } -// -// header := http.Header{} -// SpeechUrl := SpeechWs_Url + "?serviceType=websocket&productId=" + SpeechWs_ProductId + -// "&apikey=" + SpeechWs_ApiKey -// global.Logger.WithFields(logger.Fields{ -// "Header": header, -// "RequestId": data.RequestId, -// "Url": SpeechUrl, -// }).Info("[SpeechWs] dial") -// conn, resp, err := dialer.Dial(SpeechUrl, header) -// if err != nil { -// global.Logger.WithFields(logger.Fields{ -// "RequestId": data.RequestId, -// "resp": readResp(resp), -// }).Errorf("[SpeechWs] Connect error : %v", err.Error()) -// //p.Send(ErrorResponse(CodeConnectError, "connect speechWs error")) -// return -// } -// -// c := SpeechWsConnection{ -// conn: conn, -// mutex: sync.Mutex{}, -// } -// defer c.conn.Close() -// -// global.Logger.WithFields(logger.Fields{ -// "RequestId": data.RequestId, -// }).Info("[SpeechWs] Send start") -// -// SpeechWg.Add(2) -// go c.read(st, SpeechWg, data) -// go c.write(da, SpeechWg, data) -// SpeechWg.Wait() -//} -// -//func (c *SpeechWsConnection) write(v interface{}, wg *sync.WaitGroup, p model.SemanticReq) { -// defer wg.Done() -// c.mutex.Lock() -// if err := c.conn.WriteJSON(v); err != nil { -// global.Logger.WithFields(logger.Fields{ -// "data": v, -// "RequestId": p.RequestId, -// }).Errorf("[SpeechWs] write error: %v", err.Error()) -// } else { -// global.Logger.WithFields(logger.Fields{ -// "data": v, -// "RequestId": p.RequestId, -// }).Info("[SpeechWs] write success") -// } -// c.mutex.Unlock() -//} -// -//func (c *SpeechWsConnection) read(st time.Time, wg *sync.WaitGroup, p model.SemanticReq) { -// defer wg.Done() -// -// // XF使用的是追加上传 -// //var nextPos int64 -// for { -// var resp = SpeechWsResp{} -// _, message, err := c.conn.ReadMessage() -// if err != nil { -// global.Logger.WithFields(logger.Fields{ -// "RequestId": p.RequestId, -// "SpeechWsRequestId": resp.RecordId, -// }).Errorf("[SpeechWs] 读取message失败: %v", err.Error()) -// // -// //if websocket.IsCloseError(err, websocket.CloseAbnormalClosure) { -// // p.YunXiaoWeiWs() -// // continue -// //} -// -// //p.Send(ErrorResponse(CodeReadOrParseMsgError, "[SpeechWs] 读取message失败")) -// break -// } -// err = json.Unmarshal(message, &resp) -// if err != nil { -// global.Logger.WithFields(logger.Fields{ -// "RequestId": p.RequestId, -// "SpeechWsRequestId": resp.RecordId, -// }).Errorf("[SpeechWs] 解析message失败: %v", err.Error()) -// //p.Send(ErrorResponse(CodeReadOrParseMsgError, "[SpeechWs] 解析message失败")) -// return -// } -// fmt.Println(message) -// //r := resp.SpeechWsResponse(p.RequestId) -// // -// //if resp.Topic == "tts.error" { -// // global.Logger.WithFields(logger.Fields{ -// // "RequestId": p.RequestId, -// // "Code": resp.Error.ErrId, -// // "Message": resp.Error.Error, -// // "Time": time.Since(st), -// // "SpeechWsRequestId": resp.RecordId, -// // }).Error("[SpeechWs] 返回message错误") -// // r.Status.Code = int32(YXWConvertErrorCode(YXWRespCode(r.Status.Code))) -// // p.Send(r) -// // return -// //} -// //p.Send(r) -// // -// // -// //if resp.Topic == "tts.stream.end" { -// // global.Logger.WithFields(logger.Fields{ -// // "RequestId": p.RequestId, -// // "Topic": resp.Topic, -// // "Time": time.Since(st).Seconds(), -// // "SpeechWsRequestId": resp.RecordId, -// // }).Info("[SpeechWs] 读取结束") -// // -// // close(audioChan) -// // break -// //} -// } -//} -// -//func readResp(resp *http.Response) string { -// if resp == nil { -// return "" -// } -// b, err := ioutil.ReadAll(resp.Body) -// if err != nil { -// panic(err) -// } -// return fmt.Sprintf("code=%d,body=%s", resp.StatusCode, string(b)) -//} -- GitLab