Update deepgram.py

This commit is contained in:
roey
2025-03-27 17:05:29 -07:00
committed by GitHub
parent e982b3d919
commit 8aa878c5e9

View File

@@ -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)}")