Satisfy minimal text requirements for Cartesia and OpenAI
This commit is contained in:
@@ -152,7 +152,7 @@ class CartesiaTTSService(WordTTSService):
|
||||
voice_config["__experimental_controls"]["emotion"] = self._settings["emotion"]
|
||||
|
||||
msg = {
|
||||
"transcript": text,
|
||||
"transcript": text or " ", # Text must contain at least one character
|
||||
"continue": continue_transcript,
|
||||
"context_id": self._context_id,
|
||||
"model_id": self.model_name,
|
||||
@@ -271,7 +271,7 @@ class CartesiaTTSService(WordTTSService):
|
||||
yield TTSStartedFrame()
|
||||
self._context_id = str(uuid.uuid4())
|
||||
|
||||
msg = self._build_msg(text=text)
|
||||
msg = self._build_msg(text=text or " ") # Text must contain at least one character
|
||||
|
||||
try:
|
||||
await self._get_websocket().send(msg)
|
||||
|
||||
@@ -409,7 +409,7 @@ class OpenAITTSService(TTSService):
|
||||
await self.start_ttfb_metrics()
|
||||
|
||||
async with self._client.audio.speech.with_streaming_response.create(
|
||||
input=text,
|
||||
input=text or " ", # Text must contain at least one character
|
||||
model=self.model_name,
|
||||
voice=VALID_VOICES[self._voice_id],
|
||||
response_format="pcm",
|
||||
|
||||
@@ -96,7 +96,7 @@ class MarkdownTextFilter(BaseTextFilter):
|
||||
# Restore leading and trailing spaces
|
||||
filtered_text = re.sub("§", " ", filtered_text)
|
||||
|
||||
return filtered_text or " " # Return a space to satisfy TTS services
|
||||
return filtered_text
|
||||
else:
|
||||
return text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user