feat(voice): add local VAD speech endpoint detection

This commit is contained in:
chenjintao
2026-10-23 10:59:26 +08:00
parent ee32b4d63f
commit f17ce857ff
17 changed files with 1183 additions and 141 deletions
+11 -10
View File
@@ -548,15 +548,13 @@ esp_err_t platform_multimodal_audio_start_uplink(
void *user_data);
/**
* @brief 以有界方式停止多模态上行采集与流式发送任务。
* Stop multimodal uplink capture/stream worker with bounded teardown.
* @brief 暂停上行、补齐尾帧并限时排空发送;常驻 worker 留待 deinit 回收。
* Pause capture and drain the padded final frame; deinit owns workers.
*
* 负超时无效;零只请求协作停止;正超时结束时强制清理所属任务;重复调用幂等。
* Semantics:
* - `timeout_ms < 0`: invalid argument.
* - `timeout_ms == 0`: request cooperative stop and return immediately.
* - `timeout_ms > 0`: wait up to the bound, then force-delete owned workers.
* - Repeated calls are idempotent.
* 负超时无效;零只尝试立即完成,未完成返回 ESP_ERR_TIMEOUT。
* 正数预算包含等待当前采集迭代和尾包发送;成功后没有在途采集/发送。
* 超时保留队列、回调和缓冲以便重试,不后台清理;不可据此发送输入结束指令。
* 重复调用幂等;不可在 PCM observer / uplink sender 回调中调用。
*/
esp_err_t platform_multimodal_audio_stop_uplink(int timeout_ms);
bool platform_multimodal_audio_is_uplink_running(void);
@@ -571,12 +569,14 @@ bool platform_multimodal_audio_is_initialized(void);
*/
esp_err_t platform_multimodal_audio_set_speaker_output_enabled(bool enabled);
/**
* @brief 为当前采集路径注册唯一的单声道 PCM 观察者。
* Register the single mono PCM observer for the active capture path.
* @brief 为当前采集路径注册单声道 PCM 观察者(固定两个独立槽)。
* Register a mono PCM observer in one of two fixed slots.
*
* 回调在 platform 采集任务中同步执行,但不持有注册锁;回调必须有界且不可阻塞。
* The callback runs synchronously in the platform capture task, outside the
* registration lock, and must remain bounded and non-blocking.
* 相同 cb/user_data 重复注册幂等;槽位满返回 ESP_ERR_NO_MEM。
* 不得在观察者回调中注册/注销或调用音频 start/stop。
*/
esp_err_t platform_multimodal_audio_register_pcm_observer(
platform_multimodal_audio_pcm_observer_t observer,
@@ -587,6 +587,7 @@ esp_err_t platform_multimodal_audio_register_pcm_observer(
*
* 负超时无效,零只执行非阻塞的排空检查。
* Negative timeout is invalid. Zero performs a non-blocking drain check.
* 超时后槽位保持禁用且保留在途计数;必须重试成功后才能释放 user_data。
*/
esp_err_t platform_multimodal_audio_unregister_pcm_observer(
platform_multimodal_audio_pcm_observer_t observer,