feat: real service test endpoints (proxy 7-route round-trip, core/chat/vlm/markbase/embedding), unified log paths + errorLog, pipeline tools/import/export/folder APIs, face pipeline check, dynamic concurrency tuning
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled

This commit is contained in:
Accusys
2026-11-16 18:16:46 +08:00
parent d21d1ab960
commit 083d73d287
88 changed files with 12216 additions and 1096 deletions
+28 -1
View File
@@ -19,6 +19,11 @@ pub const HOP_LENGTH: usize = 160;
pub const WIN_LENGTH: usize = 400;
pub const N_BINS: usize = N_FFT / 2 + 1; // 201
pub const N_MELS: usize = 80;
/// ECAPA 嵌入的最低幀數(10ms/幀 → 16 幀 = 160ms)。
/// 不足者以循環 tile 補足 — 反映 padding 需要時間軸長度 >= 2,
/// 且太短的情緒特徵毫無意義,補足只是為了讓模型能跑完。
pub const MIN_EMBED_FRAMES: usize = 16;
const PAD: usize = N_FFT / 2;
const AMIN: f32 = 1e-10;
const TOP_DB: f32 = 80.0;
@@ -154,8 +159,30 @@ impl Ecapa {
}
/// Run the embedding network on features [n_frames, N_MELS]; returns 192-d.
///
/// ECAPA TDNN 的 conv 使用 reflect padding,時間軸過短(< 若干幀)會在
/// ONNX Pad node 崩潰:"Pad reflect requires axis length >= 2 after
/// slicing. Input shape:{1,80,1}"。長度不足的片段以循環 tile 補足到
/// MIN_EMBED_FRAMES,避免崩潰並保留粗略的說話者相似度。
pub fn embed(&mut self, feats: &[f32], n_frames: usize) -> Result<Vec<f32>> {
let input = ndarray::Array::from_shape_vec(IxDyn(&[1, n_frames, N_MELS]), feats.to_vec())
// 極短(或空)片段:無法形成有效特徵 → 回傳零向量(不參與聚類相似度)
if n_frames == 0 || feats.is_empty() {
return Ok(vec![0f32; 192]);
}
let min_frames = MIN_EMBED_FRAMES;
let (feats_vec, n_eff) = if n_frames < min_frames {
let mut padded = Vec::with_capacity(min_frames * N_MELS);
for t in 0..min_frames {
let src = t % n_frames;
padded.extend_from_slice(&feats[src * N_MELS..(src + 1) * N_MELS]);
}
(padded, min_frames)
} else {
(feats.to_vec(), n_frames)
};
let input = ndarray::Array::from_shape_vec(IxDyn(&[1, n_eff, N_MELS]), feats_vec)
.context("Failed to create ECAPA input array")?;
let input_value = Value::from_array(input).context("Failed to create input value")?;