diff --git a/asrResult/aiui/天气.json b/asrResult/aiui/天气.json new file mode 100644 index 0000000..0e54078 --- /dev/null +++ b/asrResult/aiui/天气.json @@ -0,0 +1,444 @@ +{ + "action": "result", + "code": "0", + "data": { + "auth_id": "ac30105366ea460f9ff08ddac0c4f71e", + "intent": { + "answer": { + "text": "合肥市今天全天小雨,出门记得带伞,气温5℃ ~ 16℃,空气质量良,有西北风5-6级,有点凉。", + "type": "T" + }, + "category": "IFLYTEK.weather", + "data": { + "result": [ + { + "airData": 74, + "airQuality": "良", + "city": "合肥市", + "date": "2023-03-16", + "dateLong": 1678896000, + "date_for_voice": "今天", + "exp": { + "ct": { + "expName": "穿衣指数", + "level": "温凉", + "prompt": "天气偏凉,增加衣物厚度。" + }, + "dy": { + "expName": "钓鱼指数", + "level": "较适宜", + "prompt": "气压小幅波动,可能会影响鱼儿进食。" + }, + "gm": { + "expName": "感冒指数", + "level": "极易发", + "prompt": "感冒极易发生,避免去人群密集的场所,勤洗手勤通风有利于降低感冒几率。" + }, + "jt": { + "expName": "交通指数", + "level": "较好", + "prompt": "有降水,能见度不太好且路面潮湿,不适宜高速行驶,司机应更加集中注意力,小心驾驶。" + }, + "tr": { + "expName": "旅游指数", + "level": "适宜", + "prompt": "有降水,虽然风稍大,但温度适宜,适宜旅游,可不要错过机会呦!" + }, + "uv": { + "expName": "紫外线指数", + "level": "强", + "prompt": "辐射强,请涂擦SPF大于15、PA+防晒护肤品。" + }, + "xc": { + "expName": "洗车指数", + "level": "不宜", + "prompt": "不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。" + }, + "yd": { + "expName": "运动指数", + "level": "不适宜", + "prompt": "气压有点偏低了,较不适宜在户外进行剧烈运动。" + } + }, + "extra": "", + "humidity": "80%", + "img": "http://cdn9002.iflyos.cn/osweathericon/07.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "pm25": "36", + "precipitation": "0", + "temp": 9, + "tempHigh": "16℃", + "tempLow": "5℃", + "tempRange": "5℃ ~ 16℃", + "tempReal": "4℃", + "visibility": "", + "warning": "大风蓝色预警", + "weather": "小雨", + "weatherDescription": "有点凉。", + "weatherDescription3": "4℃到8℃,今天、明天有雨,风不大,有点冷。安徽省合肥市气象台发布大风蓝色预警。", + "weatherDescription7": "10℃到8℃,今天、明天有雨,20号到22号有雨,风不大,有点凉。安徽省合肥市气象台发布大风蓝色预警。", + "weatherType": 7, + "week": "周四", + "wind": "西北风5-6级", + "windLevel": 0 + }, + { + "airData": 134, + "airQuality": "轻微污染", + "city": "合肥市", + "date": "2023-03-15", + "dateLong": 1678809600, + "date_for_voice": "昨天", + "humidity": "37%", + "img": "http://cdn9002.iflyos.cn/osweathericon/00.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "23℃", + "tempLow": "6℃", + "tempRange": "6℃ ~ 23℃", + "weather": "晴转多云", + "weatherDescription": "温度适宜。", + "weatherType": 0, + "week": "周三", + "wind": "东北风转东风3-4级", + "windLevel": 1 + }, + { + "airData": 75, + "airQuality": "良", + "city": "合肥市", + "date": "2023-03-17", + "dateLong": 1678982400, + "date_for_voice": "明天", + "humidity": "81%", + "img": "http://cdn9002.iflyos.cn/osweathericon/07.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "8℃", + "tempLow": "4℃", + "tempRange": "4℃ ~ 8℃", + "weather": "小雨转阴", + "weatherDescription": "有点冷。", + "weatherType": 7, + "week": "周五", + "wind": "东北风3-4级", + "windLevel": 1 + }, + { + "airData": 70, + "airQuality": "良", + "city": "合肥市", + "date": "2023-03-18", + "dateLong": 1679068800, + "date_for_voice": "后天", + "humidity": "66%", + "img": "http://cdn9002.iflyos.cn/osweathericon/02.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "11℃", + "tempLow": "5℃", + "tempRange": "5℃ ~ 11℃", + "weather": "阴", + "weatherDescription": "有点冷。", + "weatherType": 2, + "week": "周六", + "wind": "东北风转东风微风", + "windLevel": 0 + }, + { + "airData": 58, + "airQuality": "良", + "city": "合肥市", + "date": "2023-03-19", + "dateLong": 1679155200, + "date_for_voice": "19号", + "humidity": "62%", + "img": "http://cdn9002.iflyos.cn/osweathericon/02.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "15℃", + "tempLow": "8℃", + "tempRange": "8℃ ~ 15℃", + "weather": "阴转多云", + "weatherDescription": "有点凉。", + "weatherType": 2, + "week": "周日", + "wind": "东风3-4级", + "windLevel": 1 + }, + { + "airData": 59, + "airQuality": "良", + "city": "合肥市", + "date": "2023-03-20", + "dateLong": 1679241600, + "date_for_voice": "20号", + "humidity": "77%", + "img": "http://cdn9002.iflyos.cn/osweathericon/02.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "18℃", + "tempLow": "9℃", + "tempRange": "9℃ ~ 18℃", + "weather": "阴转小雨", + "weatherDescription": "有点凉。", + "weatherType": 2, + "week": "下周一", + "wind": "东南风转东风3-4级", + "windLevel": 1 + }, + { + "airData": 60, + "airQuality": "良", + "city": "合肥市", + "date": "2023-03-21", + "dateLong": 1679328000, + "date_for_voice": "21号", + "humidity": "89%", + "img": "http://cdn9002.iflyos.cn/osweathericon/07.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "19℃", + "tempLow": "14℃", + "tempRange": "14℃ ~ 19℃", + "weather": "小雨", + "weatherDescription": "温度适宜。", + "weatherType": 7, + "week": "下周二", + "wind": "西北风转东北风微风", + "windLevel": 0 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-22", + "dateLong": 1679414400, + "date_for_voice": "22号", + "humidity": "87%", + "img": "http://cdn9002.iflyos.cn/osweathericon/07.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "17℃", + "tempLow": "10℃", + "tempRange": "10℃ ~ 17℃", + "weather": "小雨转中雨", + "weatherDescription": "有点凉。", + "weatherType": 7, + "week": "下周三", + "wind": "东北风3-4级", + "windLevel": 1 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-23", + "dateLong": 1679500800, + "date_for_voice": "23号", + "humidity": "80%", + "img": "http://cdn9002.iflyos.cn/osweathericon/07.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "14℃", + "tempLow": "6℃", + "tempRange": "6℃ ~ 14℃", + "weather": "小雨", + "weatherDescription": "有点凉。", + "weatherType": 7, + "week": "下周四", + "wind": "东北风转西北风3-4级", + "windLevel": 1 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-24", + "dateLong": 1679587200, + "date_for_voice": "24号", + "humidity": "63%", + "img": "http://cdn9002.iflyos.cn/osweathericon/07.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "11℃", + "tempLow": "4℃", + "tempRange": "4℃ ~ 11℃", + "weather": "小雨转晴", + "weatherDescription": "有点冷。", + "weatherType": 7, + "week": "下周五", + "wind": "西北风微风", + "windLevel": 0 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-25", + "dateLong": 1679673600, + "date_for_voice": "25号", + "humidity": "67%", + "img": "http://cdn9002.iflyos.cn/osweathericon/00.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "17℃", + "tempLow": "4℃", + "tempRange": "4℃ ~ 17℃", + "weather": "晴", + "weatherDescription": "有点凉。", + "weatherType": 0, + "week": "下周六", + "wind": "东风转东南风微风", + "windLevel": 0 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-26", + "dateLong": 1679760000, + "date_for_voice": "26号", + "humidity": "61%", + "img": "http://cdn9002.iflyos.cn/osweathericon/02.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "15℃", + "tempLow": "3℃", + "tempRange": "3℃ ~ 15℃", + "weather": "阴", + "weatherDescription": "有点凉。", + "weatherType": 2, + "week": "下周日", + "wind": "东风转东南风微风", + "windLevel": 0 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-27", + "dateLong": 1679846400, + "date_for_voice": "27号", + "humidity": "59%", + "img": "http://cdn9002.iflyos.cn/osweathericon/02.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "18℃", + "tempLow": "6℃", + "tempRange": "6℃ ~ 18℃", + "weather": "阴", + "weatherDescription": "有点凉。", + "weatherType": 2, + "week": "下下周一", + "wind": "东南风转东风微风", + "windLevel": 0 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-28", + "dateLong": 1679932800, + "date_for_voice": "28号", + "humidity": "68%", + "img": "http://cdn9002.iflyos.cn/osweathericon/02.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "13℃", + "tempLow": "8℃", + "tempRange": "8℃ ~ 13℃", + "weather": "阴", + "weatherDescription": "有点冷。", + "weatherType": 2, + "week": "下下周二", + "wind": "南风微风", + "windLevel": 0 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-29", + "dateLong": 1680019200, + "date_for_voice": "29号", + "humidity": "69%", + "img": "http://cdn9002.iflyos.cn/osweathericon/02.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "20℃", + "tempLow": "11℃", + "tempRange": "11℃ ~ 20℃", + "weather": "阴", + "weatherDescription": "温度适宜。", + "weatherType": 2, + "week": "下下周三", + "wind": "东南风微风", + "windLevel": 0 + }, + { + "airData": -1, + "airQuality": "未知", + "city": "合肥市", + "date": "2023-03-30", + "dateLong": 1680105600, + "date_for_voice": "30号", + "humidity": "75%", + "img": "http://cdn9002.iflyos.cn/osweathericon/02.png", + "lastUpdateTime": "2023-03-16 20:00:08", + "tempHigh": "19℃", + "tempLow": "5℃", + "tempRange": "5℃ ~ 19℃", + "weather": "阴", + "weatherDescription": "温度适宜。", + "weatherType": 2, + "week": "下下周四", + "wind": "北风转东风3-4级", + "windLevel": 1 + } + ] + }, + "dialog_stat": "DataValid", + "rc": 0, + "save_history": true, + "semantic": [ + { + "intent": "QUERY", + "slots": [ + { + "name": "datetime", + "normValue": "{\"datetime\":\"2023-03-16\",\"suggestDatetime\":\"2023-03-16\"}", + "value": "今天" + }, + { + "name": "location.cityAddr", + "normValue": "合肥", + "value": "合肥" + }, + { + "name": "location.type", + "normValue": "LOC_BASIC", + "value": "LOC_BASIC" + }, + { + "name": "location.city", + "normValue": "合肥市", + "value": "合肥市" + }, + { + "name": "queryType", + "value": "内容" + }, + { + "name": "subfocus", + "value": "天气状态" + } + ] + } + ], + "service": "weather", + "shouldEndSession": "true", + "sid": "awa03fd9cfd@dx0001176e57b0a10b00", + "state": { + "fg::weather::default::default": { + "state": "default" + } + }, + "text": "今天天气怎么样", + "uuid": "awa03fd9cfd@dx0001176e57b0a10b00", + "version": "170.0" + }, + "is_finish": false, + "is_last": true, + "result_id": 1, + "sub": "nlp" + }, + "desc": "success", + "sid": "awa03fd9cfd@dx0001176e57b0a10b00" +} \ No newline at end of file diff --git a/cmakepc.cmake b/cmakepc.cmake index 90d0192..0cee32a 100644 --- a/cmakepc.cmake +++ b/cmakepc.cmake @@ -55,12 +55,5 @@ set(DEP_LINK_LIBRARIES # # curlpp curl ) -zadd_executable_simple(TARGET alsaplayer_main.out SRC - dep/zlinuxcomponents/alsaplayer/alsaplayer_main.cpp) -zadd_executable_simple(TARGET audio_recorder_main.out SRC - dep/zlinuxcomponents/audio/audio_recorder_main.cpp) -zadd_executable_simple(TARGET aiui_main.out SRC - dep/zlinuxcomponents/aiui_ws/aiui_main.c) -# test_aiui_service.out zadd_executable_simple(TARGET test_aiui_service.out SRC - src/test_aiui_service.cpp) +src/test_aiui_service.cpp) \ No newline at end of file diff --git a/dep/iflytopcpp b/dep/iflytopcpp index c8cd480..75c6919 160000 --- a/dep/iflytopcpp +++ b/dep/iflytopcpp @@ -1 +1 @@ -Subproject commit c8cd4807bfb283471475b180e14452b88758f63d +Subproject commit 75c691900a692c38cfdb9947446ca438efca6ee6 diff --git a/dep/zlinuxcomponents b/dep/zlinuxcomponents index 7712be1..f8ebf83 160000 --- a/dep/zlinuxcomponents +++ b/dep/zlinuxcomponents @@ -1 +1 @@ -Subproject commit 7712be17e4276764ca5d76281b69b457be7ca379 +Subproject commit f8ebf838a0aa7fdbe7915cc620875d4031c0b77a diff --git a/src/service/conversation_session.cpp b/src/service/conversation_session.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/service/conversation_session.hpp b/src/service/conversation_session.hpp new file mode 100644 index 0000000..eab3038 --- /dev/null +++ b/src/service/conversation_session.hpp @@ -0,0 +1,54 @@ +// +// Created by zwsd +// + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iflytopcpp/core/basic/nlohmann/json.hpp" +#include "iflytopcpp/core/spdlogfactory/logger.hpp" +#include "iflytopcpp/core/thread/thread.hpp" +#include "iflytopcpp/core/utils/uuid/uuid.hpp" +/** + * @brief + * + * service: ConversationSession + * + * 监听事件: + * 依赖状态: + * 依赖服务: + * 作用: + * + */ + +namespace iflytop { +using namespace std; +using namespace core; +class ConversationSession : public enable_shared_from_this { + ENABLE_LOGGER(ConversationSession); + + private: + string sessionId; + string asrTTSLocalURL; + json nlpResult; + + public: + ConversationSession() { sessionId = UUID().toString(); }; + + string getSessionId() { return sessionId; }; + + string getAsrTTSLocalURL() { return asrTTSLocalURL; }; + void setAsrTTSLocalURL(string asrTTSLocalURL) { this->asrTTSLocalURL = asrTTSLocalURL; }; + + json &getNlpResult() { return nlpResult; }; + void setNlpResult(json nlpResult) { this->nlpResult = nlpResult; }; +}; +} // namespace iflytop \ No newline at end of file diff --git a/src/service/main_control_service.cpp b/src/service/main_control_service.cpp index e644f00..c65b5a4 100644 --- a/src/service/main_control_service.cpp +++ b/src/service/main_control_service.cpp @@ -19,6 +19,171 @@ using namespace std; /********************************************************************************************************************* * ======================================================代码======================================================= * *********************************************************************************************************************/ + +void MainControlService::initializeVoiceProcess() { + m_beforeWakeupVoiceProcesser->setAmplifyDB(20); + + /** + * @brief 声卡录音回调 + * 1路,交给唤醒词预处理算法 + * 1路,在唤醒的时候交给ASR预处理算法 + */ + m_audioRecoderService->onRecordData.connect([this](shared_ptr audioClip) { + if (!audioClip) { + logger->error("onRecordData audioClip is null"); + return; + } + m_audioLoggingService->loggerMICVoice(audioClip); // 录音 + m_beforeWakeupVoiceProcesser->writeVoice(audioClip); // 交给唤醒词预处理逻辑 + if (m_conversationSession) m_beforeasrVoiceProcesser->writeVoice(audioClip); // 交给asr预处理逻辑 + }); + + /** + * @brief 唤醒词预处理算法回调 + * 1路交给唤醒词算法 + */ + m_beforeWakeupVoiceProcesser->onAfterProcessVoice.connect([this](shared_ptr audioClip) { + if (!audioClip) { + logger->error("onAfterProcessVoice audioClip is null"); + return; + } + + m_audioLoggingService->loggerBeforeWakeupVoice(audioClip); + m_wakeupProcesser->processVoice(audioClip->data(), audioClip->size()); + }); + + /** + * @brief 唤醒词触发回调 + */ + m_wakeupProcesser->onWakeupSignal.connect([this](float wakeup_score) { + logger->info("onWakeupSignal wakeup_score {}", wakeup_score); + /** + * @brief 触发唤醒,构造session + */ + m_workQueue->enQueue([this]() { constructSession(); }); + }); + + /** + * @brief asr预处理算法回调 + */ + m_beforeasrVoiceProcesser->onAfterProcessVoice.connect([this](shared_ptr audioClip) { + if (!audioClip) { + logger->error("onAfterProcessVoice audioClip is null"); + return; + } + + if (!m_conversationSession) return; + m_aiuiService->aiuiWrite((const char*)audioClip->data(), audioClip->size()); + }); + + m_aiuiService->onMessage.connect([&](json& rxjson) { + // + lock_guard lock(m_voiceprocessmutex); + json msg = rxjson; + m_workQueue->enQueue([this, msg]() { + try { + processasrResult(msg); + } catch (const std::exception& e) { + logger->error("processasrResult error:{}", e.what()); + } + }); + }); + + m_audioRecoderService->startRecord(); +} +void MainControlService::processasrResult_nlp(json& rxjson) { + logger->info("rx nlp:{}", rxjson.dump()); + m_conversationSession->setNlpResult(rxjson); + m_smartSoundboxPlayer->playConversationTTS(m_conversationSession->getAsrTTSLocalURL(), nullptr); +} +void MainControlService::processasrResult_tts(json& rxjson) { + /** + * @brief 接收从云端发过来的tts数据,并保存成文件 + */ + logger->debug("rx tts:frame {}", rxjson["data"]["json_args"]["frame_id"].get()); + bool isendFrame = false; + string ttsurl; + m_aiuiService->parseTTSContent(rxjson, isendFrame, ttsurl); + if (isendFrame) { + logger->info("rx tts end,url={}", ttsurl); + m_conversationSession->setAsrTTSLocalURL(ttsurl); + } +} + +void MainControlService::processasrResult(json rxjson) { + lock_guard lock(m_voiceprocessmutex); + + string action = rxjson["action"]; + if (action == "started") { + logger->info("processasr: rx started:{}", rxjson.dump()); + } else if (action == "error") { + logger->info("processasr: rx error:{}", rxjson.dump()); + } else if (action == "vad") { + logger->info("processasr: rx vad:{}", rxjson.dump()); + } else if (action == "result") { + string sub = rxjson["data"]["sub"]; + if (sub == "nlp") { + /** + * @brief 解析nlp数据 + */ + processasrResult_nlp(rxjson); + } else if (sub == "tts") { + /** + * @brief 解析tts数据 + */ + processasrResult_tts(rxjson); + } else if (sub == "iat") { + logger->info("rx iat:{}", rxjson.dump()); + } else if (sub == "vad") { + logger->info("rx vad:{}", rxjson.dump()); + } else { + logger->info("rx {}:{}", sub, rxjson.dump()); + } + } else { + logger->info("rx unkown:{}", rxjson.dump()); + } +} + +void MainControlService::constructSession() { + /** + * @brief + * 1. 触发唤醒词语 + * 2. 如果上一次session还没有结束,则结束上一次session + * 3. 初始化asr + * 4. 构建新的session + * 5. 启动定时器,如果10s内无人应答,则结束session + */ + + lock_guard lock(m_voiceprocessmutex); + + m_smartSoundboxPlayer->triggerWakeup(); + if (m_conversationSession) { + endSession(); + } + + m_conversationSession = make_shared(); + m_aiuiService->aiuiInit(); + + if (m_endsessionTimer->isRunning()) m_endsessionTimer->stop(); + + m_endsessionTimer->setTimeout( + [this]() { + logger->info("no hum voice detected, end session"); + endSession(); + }, + 10000); +} + +void MainControlService::endSession() { + lock_guard lock(m_voiceprocessmutex); + + if (m_conversationSession) { + m_conversationSession = nullptr; + m_aiuiService->aiuiFinished(); + m_aiuiService->aiuiDestroy(); + } +} + void MainControlService::initialize() { GET_TO_SERVICE(m_zwebService); GET_TO_SERVICE(m_deviceIOService); @@ -29,6 +194,10 @@ void MainControlService::initialize() { GET_TO_SERVICE(m_audioRecoderService); GET_TO_SERVICE(m_audioLoggingService); GET_TO_SERVICE(m_smartSoundboxPlayer); + GET_TO_SERVICE(m_aiuiService); + + m_endsessionTimer.reset(new SimpleTimer("endSessionTimer")); + m_workQueue.reset(new WorkQueue("mainControlServiceVoiceProcessCtrlWQ")); // 监听从webservice来的websocket消息 m_zwebService->startWork([this](const json& command, json& receipt) { @@ -41,36 +210,10 @@ void MainControlService::initialize() { } }); - m_beforeWakeupVoiceProcesser->setAmplifyDB(20); - - m_wakeupProcesser->onWakeupSignal.connect([this](float wakeup_score) { - logger->info("onWakeupSignal wakeup_score {}", wakeup_score); - m_smartSoundboxPlayer->triggerWakeup(); - }); - - m_audioRecoderService->onRecordData.connect([this](shared_ptr audioClip) { - if (!audioClip) { - logger->error("onRecordData audioClip is null"); - return; - } - // 1. 保存此阶段语音到文件中 - m_audioLoggingService->loggerMICVoice(audioClip); - // voice -> before wakeup - m_beforeWakeupVoiceProcesser->writeVoice(audioClip); - }); - - m_beforeWakeupVoiceProcesser->onAfterProcessVoice.connect([this](shared_ptr audioClip) { - if (!audioClip) { - logger->error("onAfterProcessVoice audioClip is null"); - return; - } - m_audioLoggingService->loggerBeforeWakeupVoice(audioClip); - // voice -> wakeup - // logger->info("before wakeup voice processer process voice size {}", audioClip->size()); - m_wakeupProcesser->processVoice(audioClip->data(), audioClip->size()); - }); - - m_audioRecoderService->startRecord(); + /** + * @brief 初始化语音处理流程 + */ + initializeVoiceProcess(); }; void MainControlService::processReceiveMessage(fromwhere_t fromwhere, const json& in, json& receipt) { logger->info("process receive message from {},{}", fromwhere2str(fromwhere), in.dump()); diff --git a/src/service/main_control_service.hpp b/src/service/main_control_service.hpp index 872c943..77f409c 100644 --- a/src/service/main_control_service.hpp +++ b/src/service/main_control_service.hpp @@ -27,6 +27,10 @@ #include "zwebservice/zwebservice.hpp" // +#include "iflytopcpp/core/components/jobs/work_queue.hpp" +#include "iflytopcpp/core/components/timer/simple_timer.hpp" +#include "service/conversation_session.hpp" +#include "zlinuxcomponents/aiui_ws/aiui_service.hpp" #include "zlinuxcomponents/alsaplayer/smart_soundbox_player.hpp" /** @@ -55,8 +59,13 @@ class MainControlService : public enable_shared_from_this { shared_ptr m_wakeupProcesser; shared_ptr m_audioRecoderService; shared_ptr m_audioLoggingService; - shared_ptr m_smartSoundboxPlayer; + shared_ptr m_conversationSession; + shared_ptr m_aiuiService; + + shared_ptr m_endsessionTimer; + shared_ptr m_workQueue; // + recursive_mutex m_voiceprocessmutex; // typedef enum { kzwebService, @@ -69,11 +78,19 @@ class MainControlService : public enable_shared_from_this { } private: - void processReceiveMessage(fromwhere_t fromwhere, const json &in, json &receipt); + void processReceiveMessage(fromwhere_t fromwhere, const json& in, json& receipt); public: MainControlService(){}; void initialize(); + + private: + void initializeVoiceProcess(); + void endSession(); + void constructSession(); + void processasrResult(json rxjson); + void processasrResult_nlp(json& rxjson); + void processasrResult_tts(json& rxjson); }; } // namespace iflytop \ No newline at end of file