From 8aa878c5e99c3d1a08a5c7d4aa1364745138f36a Mon Sep 17 00:00:00 2001 From: roey <159067767+roey-priel@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:05:29 -0700 Subject: [PATCH 1/2] Update deepgram.py --- src/pipecat/services/deepgram.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/deepgram.py b/src/pipecat/services/deepgram.py index 3750164cf..eaa82a6c9 100644 --- a/src/pipecat/services/deepgram.py +++ b/src/pipecat/services/deepgram.py @@ -97,17 +97,16 @@ class DeepgramTTSService(TTSService): # Read and yield the audio data in chunks audio_buffer.seek(0) # Ensure we're at the start of the buffer - chunk_size = 8192 # Use a fixed buffer size + chunk_size = 1024 # Use a fixed buffer size while True: await self.stop_ttfb_metrics() chunk = audio_buffer.read(chunk_size) if not chunk: + yield TTSStoppedFrame() break frame = TTSAudioRawFrame(audio=chunk, sample_rate=self.sample_rate, num_channels=1) yield frame - yield TTSStoppedFrame() - except Exception as e: logger.exception(f"{self} exception: {e}") yield ErrorFrame(f"Error getting audio: {str(e)}") From a06fc4ce50a8b71637f0a83d46039455bcf90064 Mon Sep 17 00:00:00 2001 From: roey <159067767+roey-priel@users.noreply.github.com> Date: Fri, 28 Mar 2025 08:41:36 -0700 Subject: [PATCH 2/2] yield outside of the loop --- src/pipecat/services/deepgram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pipecat/services/deepgram.py b/src/pipecat/services/deepgram.py index eaa82a6c9..689d55e9f 100644 --- a/src/pipecat/services/deepgram.py +++ b/src/pipecat/services/deepgram.py @@ -102,10 +102,10 @@ class DeepgramTTSService(TTSService): await self.stop_ttfb_metrics() chunk = audio_buffer.read(chunk_size) if not chunk: - yield TTSStoppedFrame() break frame = TTSAudioRawFrame(audio=chunk, sample_rate=self.sample_rate, num_channels=1) yield frame + yield TTSStoppedFrame() except Exception as e: logger.exception(f"{self} exception: {e}")