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.
53 lines
2.2 KiB
53 lines
2.2 KiB
#include "wakeup_processer.hpp"
|
|
using namespace std;
|
|
using namespace iflytop;
|
|
using namespace core;
|
|
|
|
#define ORDER_PATH "precise-engine/precise-engine"
|
|
// #define WAKEUP_MODULE_PATH "module/wakeup.pb"
|
|
#define CHUNK_SIZE "2048"
|
|
|
|
void WakeupProcesser::initialize(string wakeupmodulepath) {
|
|
wakeupProcesser.reset(new MycroftPreciseWapper());
|
|
wakeupProcesser->initialize(ORDER_PATH, wakeupmodulepath.c_str(), CHUNK_SIZE);
|
|
}
|
|
void WakeupProcesser::dumpwakeup_info(float source) {
|
|
if (source > 0.9) {
|
|
logger->info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++{}", source);
|
|
} else if (source > 0.8) {
|
|
logger->info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ {}", source);
|
|
} else if (source > 0.7) {
|
|
logger->info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ {}", source);
|
|
} else if (source > 0.6) {
|
|
logger->info("++++++++++++++++++++++++++++++++++++++++++++++++++ {}", source);
|
|
} else if (source > 0.4) {
|
|
logger->info("++++++++++++++++++++++++++++++++++++++++ {}", source);
|
|
} else if (source > 0.3) {
|
|
logger->info("++++++++++++++++++++++++++++++ {}", source);
|
|
} else if (source > 0.2) {
|
|
logger->info("++++++++++++++++++++ {}", source);
|
|
} else if (source > 0.1) {
|
|
logger->info("++++++++++ {}", source);
|
|
}
|
|
}
|
|
|
|
void WakeupProcesser::processVoice(uint8_t* voice, size_t voiceLen) {
|
|
wakeupProcesser->processVoice(voice, voiceLen);
|
|
wakeupProcesser->regWakeupCB([&](float wakeupscore) {
|
|
if (!wakeupflag) {
|
|
if (wakeupscore > 0.1) {
|
|
dumpwakeup_info(wakeupscore);
|
|
}
|
|
if (!wakeupflag && wakeupscore > 0.60) {
|
|
wakeupflag = true;
|
|
logger->info("detect wakeup signal {}", wakeupscore);
|
|
last_wakeup_timepoint = tu_steady().now();
|
|
onWakeupSignal(wakeupscore);
|
|
}
|
|
} else {
|
|
if (wakeupscore < 0.5 && tu_steady().elapsedTimeMs(last_wakeup_timepoint) >= 1500) {
|
|
wakeupflag = false;
|
|
}
|
|
}
|
|
});
|
|
}
|