16#ifdef USE_OTA_STATE_LISTENER
20#include <freertos/event_groups.h>
23#include <frontend_util.h>
35#ifdef USE_OTA_STATE_LISTENER
41 void setup()
override;
46#ifdef USE_OTA_STATE_LISTENER
95#ifdef USE_MICRO_WAKE_WORD_VAD
96 void add_vad_model(
const uint8_t *model_start, uint8_t probability_cutoff,
size_t sliding_window_size,
97 size_t tensor_arena_size);
116#ifdef USE_MICRO_WAKE_WORD_VAD
167 int8_t features_buffer[PREPROCESSOR_FEATURE_SIZE],
size_t *processed_samples);
Helper for FreeRTOS static task management.
void resume_task_()
Resumes the inference task.
microphone::MicrophoneSource * microphone_source_
void set_task_stack_in_psram(bool task_stack_in_psram)
QueueHandle_t detection_queue_
static void inference_task(void *params)
void process_probabilities_()
Processes any new probabilities for each model.
bool remove_runtime_model(const std::string &model_id)
Removes a runtime-downloaded wake word model and frees its interpreter, arenas, and model buffer.
EventGroupHandle_t event_group_
void set_stop_after_detection(bool stop_after_detection)
void set_state_(State state)
WakeWordModel * get_model_by_id(const std::string &model_id)
Returns the wake word model with the given id, or nullptr if none matches (compiled or runtime).
std::vector< WakeWordModel * > wake_word_models_
bool task_stack_in_psram_
void suspend_task_()
Suspends the inference task.
float get_setup_priority() const override
uint8_t get_features_step_size() const
Returns the feature step size (ms) the frontend is configured for. Runtime models must match it.
std::vector< std::string > get_runtime_model_ids()
Returns the ids of all runtime-downloaded models. Must be called from the main loop.
Trigger< std::string > wake_word_detected_trigger_
void add_wake_word_model(WakeWordModel *model)
bool generate_features_(const int16_t *audio_buffer, size_t samples_available, int8_t features_buffer[PREPROCESSOR_FEATURE_SIZE], size_t *processed_samples)
Generates a spectrogram feature from an input buffer of audio samples.
void dump_config() override
bool stop_after_detection_
bool try_lock_models_()
Parks the inference task at a safe point (or verifies it isn't running) so the model lists may be mut...
bool add_runtime_model(std::unique_ptr< WakeWordModel > model)
Adds a runtime-downloaded wake word model.
uint8_t features_step_size_
bool update_model_probabilities_(const int8_t audio_features[PREPROCESSOR_FEATURE_SIZE])
Runs an inference with each model using the new spectrogram features.
std::vector< std::unique_ptr< WakeWordModel > > runtime_models_
struct FrontendConfig frontend_config_
std::unique_ptr< VADModel > vad_model_
std::weak_ptr< ring_buffer::RingBuffer > ring_buffer_
void unlock_models_()
Releases the inference task parked by a successful try_lock_models_() call.
void add_vad_model(const uint8_t *model_start, uint8_t probability_cutoff, size_t sliding_window_size, size_t tensor_arena_size)
void set_features_step_size(uint8_t step_size)
void set_microphone_source(microphone::MicrophoneSource *microphone_source)
void unload_models_()
Deletes each model's TFLite interpreters and frees tensor arena memory.
std::vector< WakeWordModel * > get_wake_words()
StaticTask inference_task_
struct FrontendState frontend_state_
void on_ota_global_state(ota::OTAState state, float progress, uint8_t error, ota::OTAComponent *comp) override
Trigger< std::string > * get_wake_word_detected_trigger()
Listener interface for global OTA state changes (includes OTA component pointer).