[唤醒应答与快速端点]:完成唤醒后我在播报和本地VAD端点优化,包含缓冲清理、配置项和测试覆盖

This commit is contained in:
mkbk
2026-06-17 20:51:14 +08:00
parent 860c2909fc
commit 44f708a3dc
12 changed files with 224 additions and 7 deletions
+14
View File
@@ -42,6 +42,12 @@ class TransportTests(unittest.TestCase):
self.assertFalse(result.played)
self.assertEqual(result.error.code, ErrorCode.AUDIO_OUTPUT_DEVICE_MISSING)
def test_memory_transport_flushes_input_frames(self) -> None:
transport = MemoryAudioTransport([frame(1, 0), frame(2, 20)])
transport.start_input()
self.assertEqual(transport.flush_input(), 2)
self.assertEqual(transport.read_frames(10), [])
def test_file_replay_roundtrip(self) -> None:
frames = [frame(1, 0, {"wake": True}), frame(2, 20, {"speech": True})]
with tempfile.TemporaryDirectory() as tmp:
@@ -76,6 +82,14 @@ class TransportTests(unittest.TestCase):
self.assertEqual(frames[0].pcm, b"\x01\x00\x02\x00")
self.assertEqual(frames[0].sample_rate, 16000)
def test_sounddevice_transport_flushes_queued_input(self) -> None:
fake = FakeSoundDevice()
transport = SoundDeviceAudioTransport(sounddevice_module=fake)
transport.start_input(sample_rate=16000, channels=1)
self.assertEqual(transport.flush_input(), 1)
self.assertEqual(transport.read_frames(0), [])
transport.stop()
def test_sounddevice_transport_plays_pcm_to_raw_output_stream(self) -> None:
fake = FakeSoundDevice()
transport = SoundDeviceAudioTransport(sounddevice_module=fake)