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
+31 -3
View File
@@ -297,16 +297,44 @@ esp_err_t domain_runtime_multimodal_audio_start_uplink(
void *user_data);
/**
* @brief 有界停止多模态上行采集和流发送。 / Stop uplink capture/stream with bounded teardown.
* @brief 暂停采集、补齐尾帧并限时排空发送;常驻任务由 deinit 回收。
*
* `timeout_ms < 0` is invalid, zero requests asynchronous stop, and positive
* values wait up to the bound before lower layers apply deterministic fallback.
* 负超时无效;零尝试立即完成,否则 ESP_ERR_TIMEOUT;正数为完整调用预算。
* 成功后没有在途采集/发送;超时保留资源供重试,不后台清理,不应发送 StopSpeech。
*/
esp_err_t domain_runtime_multimodal_audio_stop_uplink(int timeout_ms);
bool domain_runtime_multimodal_audio_is_uplink_running(void);
bool domain_runtime_multimodal_audio_is_initialized(void);
/** 保留麦克风采集,仅控制扬声器输出。 / Gate speaker output while preserving capture. */
esp_err_t domain_runtime_multimodal_audio_set_speaker_output_enabled(bool enabled);
typedef struct {
uint32_t generation;
uint32_t min_speech_ms;
uint32_t end_silence_ms;
} domain_speech_endpoint_config_t;
typedef struct {
uint32_t generation;
bool active;
bool speech_confirmed;
bool ended;
uint32_t audio_ms;
uint32_t silence_ms;
uint32_t max_process_us;
uint32_t discontinuities;
} domain_speech_endpoint_snapshot_t;
/**
* 本地端点检测,无新 worker。start 对相同配置幂等,不同配置须先 stop。
* start/stop/get_snapshot 最多等锁 100 ms;stop 另以同一总预算等待 PCM 回调。
* stop 超时保持资源可重试,绝不后台释放;成功移除订阅并销毁 VAD。
* PCM 回调只用零等待锁及固定 20 ms 分帧,不执行协议或阻塞式收尾。
* 配置关闭时 start 返回 ESP_ERR_NOT_SUPPORTED,stop 幂等,快照为 inactive。
*/
esp_err_t domain_speech_endpoint_start(const domain_speech_endpoint_config_t *config);
esp_err_t domain_speech_endpoint_stop(void);
esp_err_t domain_speech_endpoint_get_snapshot(domain_speech_endpoint_snapshot_t *out);
/**
* @brief 启动“喵掌柜”本地 MultiNet 检测。 / Start local MultiNet detection for "喵掌柜".
*