Skip to content
Closed
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions tests/tools/test_tts_opus_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
2 changes: 1 addition & 1 deletion tools/tts_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down