tts speaks MP3: a seventh of WAV's bytes over a slow link to the server

A sentence's length for `append` comes from the Xing header LAME writes into
the first frame. The cache key carries the format, so no WAV is reused.
This commit is contained in:
Melvin Strobl
2026-10-19 21:55:17 +02:00
parent 16383ea6e2
commit f50d8b9570
4 changed files with 35 additions and 22 deletions
+6 -2
View File
@@ -189,7 +189,11 @@ async def speak(
model: str = "tts-1",
timeout: float = 30.0,
) -> bytes:
"""``POST {api_base}/audio/speech``: ``text`` spoken, as WAV."""
"""``POST {api_base}/audio/speech``: ``text`` spoken, as MP3.
MP3 rather than WAV: a seventh of the bytes, which over a slow link to
the server is most of the wait for a sentence.
"""
async with httpx.AsyncClient(timeout=timeout) as http:
response = await http.post(
api_base.rstrip("/") + "/audio/speech",
@@ -197,7 +201,7 @@ async def speak(
"model": model,
"input": text,
"voice": voice,
"response_format": "wav",
"response_format": "mp3",
},
)
if response.is_error: