From 049f110344d69db860ffbf9e573cde03ff48e2be Mon Sep 17 00:00:00 2001 From: Kwindla Hultman Kramer Date: Wed, 12 Jun 2024 09:24:09 -0700 Subject: [PATCH] PipelineTask should not exit when Deepgram TTS returns a Bad Request "unutterable" --- src/pipecat/services/deepgram.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/deepgram.py b/src/pipecat/services/deepgram.py index 6c762076f..81088a6a5 100644 --- a/src/pipecat/services/deepgram.py +++ b/src/pipecat/services/deepgram.py @@ -46,9 +46,17 @@ class DeepgramTTSService(TTSService): await self.start_ttfb_metrics() async with self._aiohttp_session.post(request_url, headers=headers, json=body) as r: if r.status != 200: - text = await r.text() - logger.error(f"Error getting audio (status: {r.status}, error: {text})") - yield ErrorFrame(f"Error getting audio (status: {r.status}, error: {text})") + response_text = await r.text() + # If we get a a "Bad Request: Input is unutterable", just print out a debug log. + # 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 async for data in r.content: