[流式回复播放]:完成LLM到TTS流式播报,包含句子切分和可取消播放队列

This commit is contained in:
mkbk
2026-06-19 12:32:32 +08:00
parent f31e3d89d6
commit 79b3e89b79
7 changed files with 206 additions and 11 deletions
+16
View File
@@ -134,6 +134,22 @@ class FullDuplexIntegrationTests(unittest.TestCase):
self.assertEqual(playback.spoken.text, "你好。")
self.assertEqual(render.frame_count, 1)
def test_full_duplex_runtime_streaming_response_writes_render_reference_and_spoken_text(self) -> None:
runtime = FullDuplexAgentRuntime(
config=AppConfig(audio_apm_provider="fake", audio_apm_required=False),
llm_provider=FakeStreamingLlmProvider(
[LlmStreamEvent("delta", "第一句。第二句。"), LlmStreamEvent("finish", finish_reason="stop")]
),
tts_provider=FakeStreamingTtsProvider(),
)
spoken = runtime.run_streaming_response_fixture([Message("user", "你好", 1.0)])
self.assertEqual(spoken, "第一句。第二句。")
self.assertIsNotNone(runtime.audio_hub)
self.assertEqual(runtime.audio_hub.render_reference.frame_count, 2)
self.assertEqual(runtime.playback_queue.pending_items, 0)
def test_memory_restart_and_tool_search_integration(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
db_path = Path(tmp) / "memory.sqlite3"