Skip to content

The agent that grows with you

fix(stt): accept .oga and .opus voice notes for transcription

Elie BRUNO971cb9b8866d
diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py
index 1674e0383aa..5ea6830119c 100644
--- a/tests/tools/test_transcription_tools.py
+++ b/tests/tools/test_transcription_tools.py
@@ -921,6 +921,16 @@ class TestValidateAudioFileEdgeCases:
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 d8418dae878..de77b836260 100644
--- a/tools/transcription_tools.py
+++ b/tools/transcription_tools.py
@@ -101,7 +101,7 @@ 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")
# DeepInfra STT base URL now resolved via hermes_cli.models.deepinfra_base_url (shared).
-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