fix(tts): transcode xAI ogg requests to Opus - #57222
Conversation
Related: implementing fix for #57213 (xAI TTS writes MP3 bytes into |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the xAI provider path. The reported behavior is still present on current main: Telegram auto voice replies request .ogg in gateway/run.py:13300-13311, while xAI writes MP3 response bytes to the requested output path in tools/tts_tool.py:1370-1413.
Problems
tools/tts_tool.py:1288raises when_convert_to_opus()returns no path, before the temporary MP3 cleanup at:1292-1295._convert_to_opus()returnsNonewithout ffmpeg on current main (tools/tts_tool.py:917-918), leaving the UUID-named MP3 behind. Gateway finalization only removes the requested/returned paths (gateway/run.py:13357-13362).
Suggested changes
- Move intermediate-file cleanup into a
finallyblock and add a regression test for the failed-conversion path.
Automated hermes-sweeper review.
|
|
||
| if needs_opus_transcode: | ||
| opus_path = _convert_to_opus(api_output_path) | ||
| if not opus_path: |
There was a problem hiding this comment.
When _convert_to_opus() returns None (including when ffmpeg is unavailable), this raises before the cleanup below, leaving the UUID-named temporary MP3 behind. Please clean up api_output_path in a finally block and add a failure-path regression test.
|
Resolved at the class level by PR #73072. Rather than a per-provider transcode, |
Fixes #57213.
Summary
.oggrequests to a temporary MP3 because xAI does not provide native Opus/OGG output.oggtarget so Telegram auto voice replies receive real Opus audio.oggrequests do not keep MP3 bytes under the.oggnameTests
scripts/run_tests.sh tests/tools/test_tts_xai_speech_tags.py -qfailed without.read_bytes() == b"mp3"before the fixscripts/run_tests.sh tests/tools/test_tts_xai_speech_tags.py -qscripts/run_tests.sh tests/tools/test_tts_xai_speech_tags.py tests/tools/test_tts_opus_routing.py tests/gateway/test_auto_voice_reply_format.py -q.venv/bin/python -m py_compile tools/tts_tool.py tests/tools/test_tts_xai_speech_tags.pygit diff --check