[ English | 简体中文 ]
Sound Model API
The Sound Model interface handles low-level acoustic model data required by the media trigger, providing model loading, unloading, property/option queries, and hotword detection capabilities.
Header: #include <media_trigger_model.h>
openvela Implementation Notes
- Relationship with Media Trigger:
media_trigger_*is the high-level voice wakeup interface (including DSP path), whilemedia_trigger_model_*is the low-level model operation interface (no audio capture involved) - Typical Usage: Custom recognition flows, running one-shot keyword detection on a specific PCM buffer
- Model Properties/Options: Use
get_propertiesto query vendor properties, andget_optionsto read recommended audio sampling parameters - One-shot Detection:
detect_hotwordperforms a single synchronous detection on a given PCM buffer
Model Lifecycle
media_trigger_model_load
void* media_trigger_model_load(const void* model, size_t size);
Loads acoustic model data and returns a model context.
Parameters:
modelPointer to the start of model data.sizeSize of the model data in bytes.
Returns:
Returns the model context pointer on success, or NULL on failure.
media_trigger_model_unload
void media_trigger_model_unload(void* context);
Unloads a previously loaded model context.
Parameters:
contextThe model context to unload.
Model Property Queries
media_trigger_model_get_properties
void media_trigger_model_get_properties(void* properties, size_t* size);
Queries vendor-provided model property information.
Parameters:
propertiesOutput buffer for storing property data.sizeInput/output parameter: on entry specifies the buffer size, on return updated to the actual number of bytes written.
media_trigger_model_get_options
void media_trigger_model_get_options(void* context, char* options, size_t size);
Queries the model's recommended audio capture options string, e.g. "format=s16le:sample_rate=16000:ch_layout=mono".
Parameters:
contextModel context (returned bymedia_trigger_model_load).optionsOutput buffer for receiving the options string.sizeOutput buffer size in bytes.
media_trigger_model_get_buffer_size
void media_trigger_model_get_buffer_size(void* context, size_t* size);
Queries the model's recommended recording buffer size.
Parameters:
contextModel context.sizeOutput parameter, returns the recommended buffer size in bytes.
Hotword Detection
media_trigger_model_detect_hotword
bool media_trigger_model_detect_hotword(void* context, const char* buffer, size_t size);
Runs a single model detection pass on the given PCM buffer to determine whether a hotword is matched.
Parameters:
contextModel context.bufferPCM audio buffer to analyze.sizeBuffer size in bytes.
Returns:
Returns true if a hotword is detected, false otherwise.