From 659c470eba542383987aad227b7f918100f131fa Mon Sep 17 00:00:00 2001
From: wangzhibo <wangzhibo@shsening.com>
Date: 星期五, 11 九月 2026 15:09:05 +0800
Subject: [PATCH] 小智终端 5种 场景模式 OK
---
xiaozhi-esp32-2.2.6/main/audio/wake_words/afe_wake_word.cc | 32 ++++++++++++++++++++++++++++----
1 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/xiaozhi-esp32-2.2.6/main/audio/wake_words/afe_wake_word.cc b/xiaozhi-esp32-2.2.6/main/audio/wake_words/afe_wake_word.cc
index bfae615..3436fac 100644
--- a/xiaozhi-esp32-2.2.6/main/audio/wake_words/afe_wake_word.cc
+++ b/xiaozhi-esp32-2.2.6/main/audio/wake_words/afe_wake_word.cc
@@ -79,6 +79,13 @@
multinet_->set_det_threshold(multinet_data_, 0.2f);
esp_mn_commands_clear();
esp_mn_commands_add(1, OFFLINE_COMMAND_WORD_PINYIN);
+ esp_mn_commands_add(2, OFFLINE_REPEATER_WORD_PINYIN);
+ esp_mn_commands_add(3, OFFLINE_START_REPEATER_WORD_PINYIN);
+ esp_mn_commands_add(4, OFFLINE_EXIT_REPEATER_WORD_PINYIN);
+ esp_mn_commands_add(5, OFFLINE_COMMAND_WORD_ALT_PINYIN);
+ esp_mn_commands_add(6, OFFLINE_CHAT_WORD_PINYIN);
+ esp_mn_commands_add(7, OFFLINE_EXIT_SHADOWING_WORD_PINYIN);
+ esp_mn_commands_add(8, OFFLINE_CHAT_WORD_FULL_PINYIN);
esp_mn_commands_update();
multinet_->print_active_speech_commands(multinet_data_);
} else {
@@ -106,7 +113,7 @@
auto this_ = (AfeWakeWord*)arg;
this_->AudioDetectionTask();
vTaskDelete(NULL);
- }, "audio_detection", 4096, this, 3, nullptr);
+ }, "audio_detection", 8192, this, 3, nullptr);
return true;
}
@@ -187,10 +194,27 @@
if (mn_state == ESP_MN_STATE_DETECTED) {
esp_mn_results_t *mn_result = multinet_->get_results(multinet_data_);
for (int i = 0; i < mn_result->num; i++) {
+ int command_id = mn_result->command_id[i];
+ const char *command_text = nullptr;
+ if (command_id == 1 || command_id == 5) {
+ command_text = OFFLINE_COMMAND_WORD;
+ } else if (command_id == 2) {
+ command_text = OFFLINE_REPEATER_WORD;
+ } else if (command_id == 3) {
+ command_text = OFFLINE_START_REPEATER_WORD;
+ } else if (command_id == 4) {
+ command_text = OFFLINE_EXIT_REPEATER_WORD;
+ } else if (command_id == 6) {
+ command_text = OFFLINE_CHAT_WORD;
+ } else if (command_id == 7) {
+ command_text = OFFLINE_EXIT_SHADOWING_WORD;
+ } else if (command_id == 8) {
+ command_text = OFFLINE_CHAT_WORD_FULL;
+ }
ESP_LOGI(TAG, "Offline command detected: command_id=%d, string=%s, prob=%f",
- mn_result->command_id[i], mn_result->string, mn_result->prob[i]);
- if (mn_result->command_id[i] == 1 && offline_command_detected_callback_) {
- offline_command_detected_callback_(OFFLINE_COMMAND_WORD);
+ command_id, mn_result->string, mn_result->prob[i]);
+ if (command_text && offline_command_detected_callback_) {
+ offline_command_detected_callback_(command_text);
}
}
multinet_->clean(multinet_data_);
--
Gitblit v1.9.1