Merge pull request #3345 from pipecat-ai/mb/avoid-tts-dot
Add trailing space to DeepgramTTSService text generation
This commit is contained in:
1
changelog/3345.fixed.md
Normal file
1
changelog/3345.fixed.md
Normal file
@@ -0,0 +1 @@
|
||||
- Fixed an issue with DeepgramTTSService where the model would output "Dot" instead of a period in some circumstances.
|
||||
@@ -287,7 +287,9 @@ class DeepgramTTSService(WebsocketTTSService):
|
||||
Yields:
|
||||
Frame: Audio frames containing the synthesized speech, plus start/stop frames.
|
||||
"""
|
||||
logger.debug(f"{self}: Generating TTS [{text}]")
|
||||
# Append trailing space to prevent TTS from vocalizing trailing periods as "dot"
|
||||
text_with_trailing_space = text + " "
|
||||
logger.debug(f"{self}: Generating TTS [{text_with_trailing_space}]")
|
||||
|
||||
try:
|
||||
# Reconnect if the websocket is closed
|
||||
@@ -295,14 +297,14 @@ class DeepgramTTSService(WebsocketTTSService):
|
||||
await self._connect()
|
||||
|
||||
await self.start_ttfb_metrics()
|
||||
await self.start_tts_usage_metrics(text)
|
||||
await self.start_tts_usage_metrics(text_with_trailing_space)
|
||||
|
||||
yield TTSStartedFrame()
|
||||
|
||||
# Send text message to Deepgram
|
||||
# Note: We don't send Flush here - that should only be sent when the
|
||||
# LLM finishes a complete response via flush_audio()
|
||||
speak_msg = {"type": "Speak", "text": text}
|
||||
speak_msg = {"type": "Speak", "text": text_with_trailing_space}
|
||||
await self._get_websocket().send(json.dumps(speak_msg))
|
||||
|
||||
# The audio frames will be handled in _receive_messages
|
||||
|
||||
Reference in New Issue
Block a user