[Frontend] Add server-side VAD for turn-based omni models (#6618)

Signed-off-by: LHXuuu <xulianhao.xlh@antgroup.com>
This commit is contained in:
LHXuuu authored and GitHub committed 2026-09-08 03:17:00 -07:00
1 parent 031612f250
commit c9c25b33c3
36 files changed
+4446 -940

No files matched your search

@@ -163,6 +163,8 @@ class TestStreamingAudioResampler:
chunked = StreamingAudioResampler(24000, 8000)
pieces = [chunked.process(chunk) for chunk in np.split(waveform, [137, 2048, 9001, 17003])]
# Bounded FIR history must own its data, not retain the last large chunk.
assert chunked._history.base is None
pieces.append(chunked.process(np.empty(0), final=True))
actual = np.concatenate(pieces)
@@ -193,9 +195,15 @@ class TestStreamingAudioResampler:
output_rms = np.sqrt(np.mean(output[100:-100] ** 2))
assert output_rms < input_rms * 0.01
def test_rejects_non_integer_downsampling_ratio(self):
with pytest.raises(ValueError, match="integer downsampling ratio"):
StreamingAudioResampler(24000, 16000)
def test_supports_rational_downsampling_ratio(self):
waveform = np.sin(np.linspace(0, 200 * np.pi, 24000, endpoint=False)).astype(np.float32)
resampler = StreamingAudioResampler(24000, 16000)
output = resampler.process(waveform, final=True)
reference = torchaudio.functional.resample(torch.from_numpy(waveform), 24000, 16000).numpy()
assert output.shape == (16000,)
np.testing.assert_allclose(output[100:-100], reference[100:-100], atol=2e-3, rtol=1e-3)
def test_rejects_multichannel_audio(self):
resampler = StreamingAudioResampler(24000, 8000)