diff --git a/tests/tools/test_tts_opus_routing.py b/tests/tools/test_tts_opus_routing.py index 0073146c30458..0a0b501fb4010 100644 --- a/tests/tools/test_tts_opus_routing.py +++ b/tests/tools/test_tts_opus_routing.py @@ -68,3 +68,32 @@ def fake_convert(path: str) -> str: assert result["voice_compatible"] is True assert result["media_tag"] == f"[[audio_as_voice]]\nMEDIA:{opus}" convert.assert_called_once_with(str(out)) + + +def test_minimax_feishu_converts_to_opus_voice(tmp_path, monkeypatch): + out = tmp_path / "speech.mp3" + opus = tmp_path / "speech.ogg" + + def fake_convert(path: str) -> str: + assert path == str(out) + opus.write_bytes(b"ogg") + return str(opus) + + convert = Mock(side_effect=fake_convert) + + monkeypatch.setenv("HERMES_SESSION_PLATFORM", "feishu") + monkeypatch.setattr(tts_tool, "_load_tts_config", lambda: {"provider": "minimax"}) + monkeypatch.setattr( + tts_tool, + "_generate_minimax_tts", + lambda _text, _output, _cfg: (_ := Path(_output).write_bytes(b"mp3")) or _output, + ) + monkeypatch.setattr(tts_tool, "_convert_to_opus", convert) + + result = json.loads(tts_tool.text_to_speech_tool("hello", output_path=str(out))) + + assert result["success"] is True + assert result["file_path"] == str(opus) + assert result["voice_compatible"] is True + assert result["media_tag"] == f"[[audio_as_voice]]\nMEDIA:{opus}" + convert.assert_called_once_with(str(out)) diff --git a/tools/tts_tool.py b/tools/tts_tool.py index c6e7c22de0f0d..8dd547ee61ccf 100644 --- a/tools/tts_tool.py +++ b/tools/tts_tool.py @@ -2064,7 +2064,7 @@ def text_to_speech_tool( # and needs ffmpeg for conversion. from gateway.session_context import get_session_env platform = get_session_env("HERMES_SESSION_PLATFORM", "").lower() - want_opus = (platform == "telegram") + want_opus = platform in {"telegram", "feishu"} # Determine output path if output_path: