Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tools/tts_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,9 +997,17 @@ def _generate_openai_tts(text: str, output_path: str, tts_config: Dict[str, Any]
base_url = oai_config.get("base_url", base_url)
speed = float(oai_config.get("speed", tts_config.get("speed", 1.0)))

# Determine response format from extension
# Determine response format from extension. Mirror the Mistral provider so a
# configured wav/flac output_format is honored instead of always forcing mp3.
# wav/flac are valid OpenAI audio.speech response_format values, and some
# OpenAI-compatible backends only implement native WAV (e.g. Chatterbox-TTS-Server),
# where forcing mp3 yields a hard "500: Failed to encode audio".
if output_path.endswith(".ogg"):
response_format = "opus"
elif output_path.endswith(".wav"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please normalize the suffix once (for example, Path(output_path).suffix.lower()) before this mapping. text_to_speech_tool() preserves a caller-provided path, so .WAV and .FLAC currently still fall through to mp3.

response_format = "wav"
elif output_path.endswith(".flac"):
response_format = "flac"
else:
response_format = "mp3"

Expand Down