Merge pull request #1288 from pipecat-ai/mb/clean-up-tts-text-input

TTSService: Remove newlines before sending text to TTS service to gen…
This commit is contained in:
Mark Backman
2025-02-25 14:00:43 -05:00
committed by GitHub
2 changed files with 7 additions and 0 deletions

View File

@@ -32,6 +32,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- The base `TTSService` class now strips leading newlines before sending text
to the TTS provider. This change is to solve issues where some TTS providers,
like Azure, would not output text due to newlines.
- `GrokLLMSService` now uses `grok-2` as the default model.
- `AnthropicLLMService` now uses `claude-3-7-sonnet-20250219` as the default

View File

@@ -399,6 +399,9 @@ class TTSService(AIService):
await self._push_tts_frames(text)
async def _push_tts_frames(self, text: str):
# Remove leading newlines only
text = text.lstrip("\n")
# Don't send only whitespace. This causes problems for some TTS models. But also don't
# strip all whitespace, as whitespace can influence prosody.
if not text.strip():