forked from xiaozhi/xiaozhi-esp32
feat: sensecap watcher add inference (#1312)
* feat: Wake up when a person is detected * fix: Solve the problem of no sound when using WakeWordInvoke * fix: Solve the problem of triggering dialogue when the person has not left * feat(vision): 优化视觉检测逻辑并增加配置接口 本次提交旨在优化视觉检测功能,使其行为更自然、更智能,并为用户提供灵活的配置选项。 主要更新包括: 1. 引入了更精细的检测状态机: - IDLE: 空闲状态,等待检测目标。 - VALIDATING: 验证状态,在检测到目标后,持续一段时间(可配置)以确认其存在,防止误触发。 - COOLDOWN: 冷却状态,在一次成功交互后进入,避免过于频繁的打扰。 2. 新增了用于配置视觉检测的 MCP 工具: - self.vision.get_detection_config: 获取当前的检测参数(阈值、冷却间隔、验证时长、目标类型)。 - self.vision.set_detection_config: 允许用户动态修改这些参数,以适应不同场景。 3. 性能优化: - 增加了配置参数的内存缓存,避免了在检测循环中对 NVS 的频繁访问。 * feat: Inference using Model 4 * feat: default inference disable * feat: version cmd change to output json * fix: fix image display * Fix include directives for esp_check and esp_app_desc --------- Co-authored-by: Spencer <love4yzp@gmail.com> Co-authored-by: Xiaoxia <terrence@tenclass.com>
This commit is contained in:
@@ -788,13 +788,35 @@ bool Application::UpgradeFirmware(Ota& ota, const std::string& url) {
|
||||
}
|
||||
|
||||
void Application::WakeWordInvoke(const std::string& wake_word) {
|
||||
if (!protocol_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (device_state_ == kDeviceStateIdle) {
|
||||
ToggleChatState();
|
||||
Schedule([this, wake_word]() {
|
||||
if (protocol_) {
|
||||
protocol_->SendWakeWordDetected(wake_word);
|
||||
audio_service_.EncodeWakeWord();
|
||||
|
||||
if (!protocol_->IsAudioChannelOpened()) {
|
||||
SetDeviceState(kDeviceStateConnecting);
|
||||
if (!protocol_->OpenAudioChannel()) {
|
||||
audio_service_.EnableWakeWordDetection(true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Wake word detected: %s", wake_word.c_str());
|
||||
#if CONFIG_USE_AFE_WAKE_WORD || CONFIG_USE_CUSTOM_WAKE_WORD
|
||||
// Encode and send the wake word data to the server
|
||||
while (auto packet = audio_service_.PopWakeWordPacket()) {
|
||||
protocol_->SendAudio(std::move(packet));
|
||||
}
|
||||
// Set the chat state to wake word detected
|
||||
protocol_->SendWakeWordDetected(wake_word);
|
||||
SetListeningMode(aec_mode_ == kAecOff ? kListeningModeAutoStop : kListeningModeRealtime);
|
||||
#else
|
||||
SetListeningMode(aec_mode_ == kAecOff ? kListeningModeAutoStop : kListeningModeRealtime);
|
||||
// Play the pop up sound to indicate the wake word is detected
|
||||
audio_service_.PlaySound(Lang::Sounds::OGG_POPUP);
|
||||
#endif
|
||||
} else if (device_state_ == kDeviceStateSpeaking) {
|
||||
Schedule([this]() {
|
||||
AbortSpeaking(kAbortReasonNone);
|
||||
|
||||
Reference in New Issue
Block a user