fix(tts): include feishu in want_opus platforms - #45761
Conversation
|
Great fix — the The problem: # feishu.py:4861
def _resolve_outbound_file_routing(file_path, requested_message_type):
ext = Path(file_path).suffix.lower()
if ext in _FEISHU_OPUS_UPLOAD_EXTENSIONS: # {.ogg, .opus}
return "opus", "audio"
if ext in _FEISHU_MEDIA_UPLOAD_EXTENSIONS: # {.mp4, .mov, ...}
return "mp4", "media"
if ext in _FEISHU_DOC_UPLOAD_TYPES:
return _FEISHU_DOC_UPLOAD_TYPES[ext], "file"
if requested_message_type == "file": # ← only checks "file"
return _FEISHU_FILE_UPLOAD_TYPE, "file"
return _FEISHU_FILE_UPLOAD_TYPE, "file" # ← .mp3/.wav/.m4a fall through hereSo even with this PR's Suggested addition (after the Opus check): if requested_message_type == "audio" and ext in _AUDIO_EXTENSIONS:
return "stream", "audio"This makes the Happy to help test or split this into a separate PR if you'd prefer to keep this one focused. Either way, the |
_requested_message_type_ was being ignored for non-Opus audio files (MP3/WAV/M4A). When send_voice() passes outbound_message_type='audio', _resolve_outbound_file_routing() still fell through to msg_type=file because it only checked the file extension against _FEISHU_OPUS_UPLOAD_EXTENSIONS. Feishu's im.v1.file.create accepts any audio uploaded as file_type=opus without codec validation — MP3/WAV/M4A all render as voice bubbles when sent with msg_type=audio. Tested end-to-end against the live API. Giving requested_message_type='audio' priority over the extension check fixes the fallback and makes the parameter meaningful. Co-authored-by: <reviewer>@users.noreply.github.com
f4b0bb3 to
89749a8
Compare
Good catch on _resolve_outbound_file_routing — I checked and you're right, non-Opus audio files fall through to msg_type=file even when send_voice() passes outbound_message_type="audio". I'll push this to the PR along with the want_opus fix since they're the same bug chain. Thanks for pointing it out. |
Duplicate of #45712 — identical one-line |
|
Thanks for covering both the TTS conversion path and the no-ffmpeg fallback. The premise remains valid on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
|
The root cause here (gateway auto-TTS choosing MP3 vs Ogg/Opus via the cleared (Landed via #73508, merge |
What does this PR do?
Extends
want_opusplatform set to includefeishualongsidetelegram, so minimax TTS on Feishu converts mp3 → ogg and gets delivered as voice bubble instead of file attachment.Related Issue
Fixes #45557
Type of Change
Changes Made
tools/tts_tool.py: changedwant_opus = (platform == 'telegram')→want_opus = platform in {'telegram', 'feishu'}tests/tools/test_tts_opus_routing.py: addedtest_minimax_feishu_converts_to_opus_voiceHow to Test
PYTHONPATH=. venv/bin/python -m pytest tests/tools/test_tts_opus_routing.py -v— all 3 tests passChecklist
fix(tts):)PYTHONPATH=. venv/bin/python -m pytest tests/tools/test_tts_opus_routing.py -q— all pass