#ifndef CUSTOM_WAKE_WORD_H #define CUSTOM_WAKE_WORD_H #include #include #include #include #include #include #include #include #include #include #include #include "audio_codec.h" #include "wake_word.h" class CustomWakeWord : public WakeWord { public: CustomWakeWord(); ~CustomWakeWord(); bool Initialize(AudioCodec* codec, srmodel_list_t* models_list); void Feed(const std::vector& data); void OnWakeWordDetected(std::function callback); void Start(); void Stop(); size_t GetFeedSize(); void EncodeWakeWordData(); bool GetWakeWordOpus(std::vector& opus); const std::string& GetLastDetectedWakeWord() const { return last_detected_wake_word_; } private: struct Command { std::string command; std::string text; std::string action; }; // multinet 相关成员变量 esp_mn_iface_t* multinet_ = nullptr; model_iface_data_t* multinet_model_data_ = nullptr; srmodel_list_t *models_ = nullptr; char* mn_name_ = nullptr; std::string language_ = "cn"; int duration_ = 3000; float threshold_ = 0.2; std::deque commands_; std::function wake_word_detected_callback_; AudioCodec* codec_ = nullptr; std::string last_detected_wake_word_; std::atomic running_ = false; TaskHandle_t wake_word_encode_task_ = nullptr; StaticTask_t* wake_word_encode_task_buffer_ = nullptr; StackType_t* wake_word_encode_task_stack_ = nullptr; std::deque> wake_word_pcm_; std::deque> wake_word_opus_; std::mutex wake_word_mutex_; std::condition_variable wake_word_cv_; void StoreWakeWordData(const std::vector& data); void ParseWakenetModelConfig(); }; #endif