Merge pull request #1524 from pipecat-ai/mb/tts-generate-with-text

TTS: Skip generation when there is no text
This commit is contained in:
Mark Backman
2025-04-07 14:44:18 -04:00
committed by GitHub
3 changed files with 5 additions and 4 deletions

View File

@@ -158,7 +158,7 @@ class CartesiaTTSService(AudioContextWordTTSService):
voice_config["__experimental_controls"]["emotion"] = self._settings["emotion"]
msg = {
"transcript": text or " ", # Text must contain at least one character
"transcript": text,
"continue": continue_transcript,
"context_id": self._context_id,
"model_id": self.model_name,
@@ -287,7 +287,7 @@ class CartesiaTTSService(AudioContextWordTTSService):
self._context_id = str(uuid.uuid4())
await self.create_audio_context(self._context_id)
msg = self._build_msg(text=text or " ") # Text must contain at least one character
msg = self._build_msg(text=text)
try:
await self._get_websocket().send(msg)

View File

@@ -105,7 +105,7 @@ class OpenAITTSService(TTSService):
extra_body["instructions"] = self._instructions
async with self._client.audio.speech.with_streaming_response.create(
input=text or " ", # Text must contain at least one character
input=text,
model=self.model_name,
voice=VALID_VOICES[self._voice_id],
response_format="pcm",

View File

@@ -269,7 +269,8 @@ class TTSService(AIService):
filter.reset_interruption()
text = filter.filter(text)
await self.process_generator(self.run_tts(text))
if text:
await self.process_generator(self.run_tts(text))
await self.stop_processing_metrics()