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
10 changes: 10 additions & 0 deletions tests/tools/test_transcription_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tools/transcription_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current Telegram inbound voice handling already forces .ogg (plugins/platforms/telegram/adapter.py:7849-7853), while WhatsApp deliberately maps .oga to .ogg because downstream STT expects that filename (gateway/platforms/whatsapp_cloud.py:129-164). Please establish provider-safe canonicalization before adding .oga to the shared allowlist; this change otherwise forwards the .oga basename unchanged to cloud providers.

MAX_FILE_SIZE = 25 * 1024 * 1024 # 25 MB

Expand Down