You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.3 KiB
156 lines
5.3 KiB
#include <curl/curl.h>
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
#include "zlinuxcomponents/aiui_ws/aiui_service.hpp"
|
|
#include "zlinuxcomponents/alsaplayer/AudioPlayerAlsaImpl.hpp"
|
|
#include "zlinuxcomponents/alsaplayer/smart_soundbox_player.hpp"
|
|
#include "zlinuxcomponents/zmainhelper.hpp"
|
|
//
|
|
#include "configs/config.hpp"
|
|
#include "iflytopcpp/core/spdlogfactory/logger.hpp"
|
|
#include "iflytopcpp/core/thread/thread.hpp"
|
|
#include "version.hpp"
|
|
#include "zlinuxcomponents/rootfs_auto_update/rootfs_auto_update.hpp"
|
|
#include "zservice_container/zservice_container.hpp"
|
|
#include "zwebservice/zwebservice.hpp"
|
|
//
|
|
#include "service/device_io_service.hpp"
|
|
#include "service/device_io_service_mock.hpp"
|
|
#include "service/light_control_service.hpp"
|
|
#include "service/main_control_service.hpp"
|
|
#include "service/report_service.hpp"
|
|
#include "service/voiceprocess/audio_recoder_service.hpp"
|
|
#include "service/voiceprocess/beforeasr_voiceprocesser.hpp"
|
|
#include "service/voiceprocess/beforewakeup_voiceprocesser.hpp"
|
|
#include "service/voiceprocess/voiceprocess_service.hpp"
|
|
#include "service/voiceprocess/wakeup_processer.hpp"
|
|
//
|
|
|
|
using namespace iflytop;
|
|
using namespace core;
|
|
using namespace std;
|
|
using namespace clipp;
|
|
|
|
ZMAIN();
|
|
/***********************************************************************************************************************
|
|
* =======================================================Main======================================================== *
|
|
***********************************************************************************************************************/
|
|
void Main::onSIGINT() { exit(0); }
|
|
int Main::main(int argc, char *argv[]) {
|
|
string g_host_server_ip;
|
|
string g_device_id;
|
|
#if 0
|
|
auto cli = ( //
|
|
(required("-device_id") & value("device_id", g_device_id)).doc("device_id") //
|
|
);
|
|
if (!parse(argc, argv, cli)) {
|
|
cout << make_man_page(cli, argv[0]);
|
|
exit(-1);
|
|
}
|
|
#endif
|
|
|
|
logger->info("system setup start.");
|
|
spdlog::flush_on(spdlog::level::debug);
|
|
|
|
logger->info("#");
|
|
logger->info("# company:{}", "ifytop");
|
|
logger->info("# version:{}", VERSION);
|
|
logger->info("#");
|
|
|
|
// BUILD_AND_REG_SERRVICE(Config);
|
|
logger->info("build {}.....", "Config");
|
|
shared_ptr<iflytop::Config> Config_val(new iflytop::Config());
|
|
ServiceContrainer::get().regService(Config_val);
|
|
GET_SERVICE(iflytop::Config)->initialize();
|
|
if (!g_device_id.empty()) GET_SERVICE(iflytop::Config)->set_deviceId(g_device_id);
|
|
|
|
/**
|
|
* @brief 比较rootfs目录中的文件和系统中对应路径的文件是否一致,如果不一致则替换
|
|
*
|
|
* 例如
|
|
* ./rootfs/etc/asound.conf 和 /etc/asound.conf 不一致,则替换
|
|
*
|
|
*/
|
|
auto rootfsAutoUpdate = make_shared<RootfsAutoUpdate>();
|
|
rootfsAutoUpdate->compareAndReplace();
|
|
logger->info("rootfs changed:{}", rootfsAutoUpdate->isChanged() ? "yes" : "no");
|
|
if (rootfsAutoUpdate->isChanged()) {
|
|
logger->info("reboot system.");
|
|
logger->warn("not auto reboot, please reboot manually.");
|
|
// system("reboot");
|
|
}
|
|
|
|
/**
|
|
* @brief DeviceIOService初始化
|
|
*/
|
|
#if 0
|
|
BUILD_AND_REG_SERRVICE(DeviceIOService);
|
|
#else
|
|
BUILD_AND_REG_MOCK_SERRVICE(DeviceIOService, DeviceIOServiceMock);
|
|
#endif
|
|
GET_SERVICE(DeviceIOService)->initialize();
|
|
|
|
/**
|
|
* @brief 音频处理相关组建初始化
|
|
*/
|
|
|
|
// 音频采集
|
|
BUILD_AND_REG_SERRVICE(AudioRecoderService);
|
|
GET_SERVICE(AudioRecoderService)->initialize("recorder", 5, 16000, SND_PCM_FORMAT_S16_LE);
|
|
|
|
// BeforeWakeupVoiceProcesser
|
|
BUILD_AND_REG_SERRVICE(BeforeWakeupVoiceProcesser);
|
|
GET_SERVICE(BeforeWakeupVoiceProcesser)->initialize();
|
|
|
|
// BeforeAsrVoiceProcesser
|
|
BUILD_AND_REG_SERRVICE(BeforeasrVoiceProcesser);
|
|
GET_SERVICE(BeforeasrVoiceProcesser)->initialize();
|
|
|
|
// WakeupProcesser
|
|
BUILD_AND_REG_SERRVICE(WakeupProcesser);
|
|
GET_SERVICE(WakeupProcesser)->initialize("xiaomaoxiaomao/xiaomaoxiaomao.pb");
|
|
|
|
// AsrProcesser
|
|
const char *appid = "5938b7c7"; // 应用ID,在AIUI开放平台创建并设置
|
|
const char *key = "19c1f7becc78eedc7826b485aabe30de"; // 接口密钥,在AIUI开放平台查看
|
|
json paramj;
|
|
paramj["result_level"] = "plain";
|
|
paramj["auth_id"] = "ac30105366ea460f9ff08ddac0c4f71e";
|
|
paramj["data_type"] = "text";
|
|
paramj["scene"] = "main_box";
|
|
paramj["sample_rate"] = "16000";
|
|
paramj["context"] = R"({"sdk_support":["nlp","tts","vad","iat"]})";
|
|
BUILD_AND_REG_SERRVICE(AiuiService);
|
|
GET_SERVICE(AiuiService)->initialize(appid, key, paramj.dump());
|
|
|
|
// 播放器-SmartSoundBoxPlayer
|
|
BUILD_AND_REG_SERRVICE(SmartSoundBoxPlayer);
|
|
//
|
|
GET_SERVICE(SmartSoundBoxPlayer)->initialize(80);
|
|
|
|
// VoiceProcessService
|
|
BUILD_AND_REG_SERRVICE(VoiceProcessService);
|
|
GET_SERVICE(VoiceProcessService)->initialize();
|
|
|
|
/**
|
|
* @brief 其他服务
|
|
*/
|
|
BUILD_AND_REG_SERRVICE(ZWebService);
|
|
GET_SERVICE(ZWebService)->initialize();
|
|
|
|
BUILD_AND_REG_SERRVICE(LightControlService);
|
|
GET_SERVICE(LightControlService)->initialize();
|
|
GET_SERVICE(LightControlService)->start();
|
|
|
|
BUILD_AND_REG_SERRVICE(ReportService);
|
|
GET_SERVICE(ReportService)->initialize();
|
|
GET_SERVICE(ReportService)->start();
|
|
|
|
BUILD_AND_REG_SERRVICE(MainControlService);
|
|
GET_SERVICE(MainControlService)->initialize();
|
|
|
|
logger->info("system setup end.");
|
|
while (true) sleep(1000);
|
|
}
|