wangzhibo
2026-08-26 70481429367ca00144b24f118cbfdfb28b02967d
xiaozhi-esp32-2.2.6/main/audio/wake_words/afe_wake_word.h
@@ -6,6 +6,7 @@
#include <freertos/event_groups.h>
#include <esp_afe_sr_models.h>
#include <esp_mn_iface.h>
#include <esp_nsn_models.h>
#include <model_path.h>
@@ -27,6 +28,7 @@
    bool Initialize(AudioCodec* codec, srmodel_list_t* models_list);
    void Feed(const std::vector<int16_t>& data);
    void OnWakeWordDetected(std::function<void(const std::string& wake_word)> callback);
    void OnOfflineCommandDetected(std::function<void(const std::string& command)> callback);
    void Start();
    void Stop();
    size_t GetFeedSize();
@@ -39,12 +41,17 @@
    const esp_afe_sr_iface_t* afe_iface_ = nullptr;
    esp_afe_sr_data_t* afe_data_ = nullptr;
    char* wakenet_model_ = NULL;
    char* multinet_model_ = NULL;
    esp_mn_iface_t* multinet_ = nullptr;
    model_iface_data_t* multinet_data_ = nullptr;
    std::vector<std::string> wake_words_;
    EventGroupHandle_t event_group_;
    std::function<void(const std::string& wake_word)> wake_word_detected_callback_;
    std::function<void(const std::string& command)> offline_command_detected_callback_;
    AudioCodec* codec_ = nullptr;
    std::string last_detected_wake_word_;
    std::vector<int16_t> input_buffer_;
    std::vector<int16_t> multinet_input_buffer_;
    std::mutex input_buffer_mutex_;
    TaskHandle_t wake_word_encode_task_ = nullptr;