PipelineTask should not exit when Deepgram TTS returns a Bad Request "unutterable"

This commit is contained in:
Kwindla Hultman Kramer
2024-06-12 09:24:09 -07:00
parent 448a0307a8
commit 049f110344

View File

@@ -46,9 +46,17 @@ class DeepgramTTSService(TTSService):
await self.start_ttfb_metrics() await self.start_ttfb_metrics()
async with self._aiohttp_session.post(request_url, headers=headers, json=body) as r: async with self._aiohttp_session.post(request_url, headers=headers, json=body) as r:
if r.status != 200: if r.status != 200:
text = await r.text() response_text = await r.text()
logger.error(f"Error getting audio (status: {r.status}, error: {text})") # If we get a a "Bad Request: Input is unutterable", just print out a debug log.
yield ErrorFrame(f"Error getting audio (status: {r.status}, error: {text})") # All other unsuccesful requests should emit an error frame. If not specifically
# handled by the running PipelineTask, the ErrorFrame will cancel the task.
if "unutterable" in response_text:
logger.debug(f"Unutterable text: [{text}]")
return
logger.error(
f"Error getting audio (status: {r.status}, error: {response_text})")
yield ErrorFrame(f"Error getting audio (status: {r.status}, error: {response_text})")
return return
async for data in r.content: async for data in r.content: