diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py index 434971e9aac4..3f487ff2a412 100644 --- a/tests/tools/test_transcription_tools.py +++ b/tests/tools/test_transcription_tools.py @@ -811,6 +811,16 @@ def test_all_supported_formats_accepted(self, tmp_path): f.write_bytes(b"data") assert _validate_audio_file(str(f)) is None, f"Format {fmt} should be accepted" + def test_telegram_oga_and_opus_accepted(self, tmp_path): + # Telegram delivers voice notes as .oga (OGG/Opus); .opus is the + # bare-codec sibling. Both must pass validation or every inbound + # voice note fails before reaching any STT backend. + from tools.transcription_tools import _validate_audio_file + for fmt in (".oga", ".opus"): + f = tmp_path / f"voice{fmt}" + f.write_bytes(b"data") + assert _validate_audio_file(str(f)) is None + def test_case_insensitive_extension(self, tmp_path): from tools.transcription_tools import _validate_audio_file f = tmp_path / "test.MP3" diff --git a/tools/transcription_tools.py b/tools/transcription_tools.py index d0712c81e1eb..8c19af41bcc3 100644 --- a/tools/transcription_tools.py +++ b/tools/transcription_tools.py @@ -99,7 +99,7 @@ def _safe_find_spec(module_name: str) -> bool: XAI_STT_BASE_URL = os.getenv("XAI_STT_BASE_URL", "https://api.x.ai/v1") ELEVENLABS_STT_BASE_URL = os.getenv("ELEVENLABS_STT_BASE_URL", "https://api.elevenlabs.io/v1") -SUPPORTED_FORMATS = {".mp3", ".mp4", ".mpeg", ".mpga", ".m4a", ".wav", ".webm", ".ogg", ".aac", ".flac"} +SUPPORTED_FORMATS = {".mp3", ".mp4", ".mpeg", ".mpga", ".m4a", ".wav", ".webm", ".ogg", ".oga", ".opus", ".aac", ".flac"} LOCAL_NATIVE_AUDIO_FORMATS = {".wav", ".aiff", ".aif"} MAX_FILE_SIZE = 25 * 1024 * 1024 # 25 MB