refactor: formaliza formatos de áudio e alinhamento PCM

This commit is contained in:
alex alves
2026-11-03 16:43:22 -03:00
parent 4d7ff46a36
commit 76d15b8e52
23 changed files with 349 additions and 82 deletions

View File

@@ -1,5 +1,4 @@
from voice_assistant.agent.adapter import StreamingAgentAdapter
from voice_assistant.tts.adapter import TTSAdapter
"""
Tests for the Voice Pipeline lifecycle orchestration.
@@ -850,9 +849,9 @@ async def test_stream_turn_response_produces_audio_before_agent_finishes():
yield " Estou à disposição."
self.finished = True
class StreamingTTS(TTSAdapter):
class StreamingTTS(MockTTSAdapter):
async def synthesize(self, text):
yield text.encode("utf-8")
yield text.encode("utf-16-le")
agent = StreamingAgent()
@@ -938,9 +937,9 @@ async def test_stream_turn_response_propagates_agent_failure():
yield "Olá, como posso ajudar?"
raise RuntimeError("Simulated OCI streaming failure.")
class StreamingTTS(TTSAdapter):
class StreamingTTS(MockTTSAdapter):
async def synthesize(self, text):
yield text.encode("utf-8")
yield text.encode("utf-16-le")
pipeline = VoicePipeline(
session=SessionState(session_id="agent-failure-session"),
@@ -984,7 +983,7 @@ async def test_stream_turn_response_cancels_agent_on_tts_failure():
finally:
self.cancelled.set()
class FailingTTS(TTSAdapter):
class FailingTTS(MockTTSAdapter):
async def synthesize(self, text):
raise RuntimeError("Simulated TTS failure.")
yield b"" # Keep this method an async generator.
@@ -1036,7 +1035,7 @@ async def test_stream_turn_response_external_cancellation():
finally:
self.closed.set()
class BlockingTTS(TTSAdapter):
class BlockingTTS(MockTTSAdapter):
def __init__(self):
self.started = asyncio.Event()
self.closed = asyncio.Event()
@@ -1045,7 +1044,7 @@ async def test_stream_turn_response_external_cancellation():
try:
self.started.set()
await asyncio.Event().wait()
yield b"audio"
yield b"audi"
finally:
self.closed.set()