Skip to content

Commit 1e7998d

Browse files
author
LittleMouse
committed
[fix] Fix print log
1 parent b7acc2d commit 1e7998d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

backend/tts_client_backend.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,13 @@ def _count_tokens(self, text: str) -> int:
138138
return len(self.tokenizer.encode(text))
139139

140140
async def generate_speech(self, input_text: str, voice: str = "prompt_data", format: str = "mp3") -> AsyncGenerator[bytes, None]:
141-
if self._count_tokens(input_text) > self.MAX_CONTEXT_LENGTH:
142-
self.logger.warning(
143-
f"Input text length ({len(input_text)}) exceeds max context length ({self.MAX_CONTEXT_LENGTH})."
144-
)
145-
raise ValueError(
146-
f"Text too long: {len(input_text)} characters. "
147-
f"Maximum allowed: {self.MAX_CONTEXT_LENGTH}."
141+
token_count = self._count_tokens(input_text)
142+
if token_count > self.MAX_CONTEXT_LENGTH:
143+
msg = (
144+
f"Input token count ({token_count}) exceeds max context length ({self.MAX_CONTEXT_LENGTH})."
148145
)
146+
self.logger.warning(msg)
147+
raise ValueError(msg)
149148

150149
client = await self._get_client(voice)
151150
task = asyncio.current_task()

0 commit comments

Comments
 (0)