diff --git a/backend/open_webui/routers/audio.py b/backend/open_webui/routers/audio.py index 0816cdcde3..120300d49e 100644 --- a/backend/open_webui/routers/audio.py +++ b/backend/open_webui/routers/audio.py @@ -1151,10 +1151,9 @@ def transcription( user=Depends(get_verified_user), ): log.info(f"file.content_type: {file.content_type}") - stt_supported_content_types = getattr( request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", [] - ) or ["audio/*", "video/webm"] + ) if not strict_match_mime_type(stt_supported_content_types, file.content_type): raise HTTPException( diff --git a/backend/open_webui/routers/files.py b/backend/open_webui/routers/files.py index 723a150197..7f01537e66 100644 --- a/backend/open_webui/routers/files.py +++ b/backend/open_webui/routers/files.py @@ -114,7 +114,7 @@ def process_uploaded_file(request, file, file_path, file_item, file_metadata, us if file.content_type: stt_supported_content_types = getattr( request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", [] - ) or ["audio/*", "video/webm"] + ) if strict_match_mime_type(stt_supported_content_types, file.content_type): file_path = Storage.get_file(file_path) diff --git a/backend/open_webui/utils/misc.py b/backend/open_webui/utils/misc.py index 85f47719b6..e293f3d257 100644 --- a/backend/open_webui/utils/misc.py +++ b/backend/open_webui/utils/misc.py @@ -622,6 +622,10 @@ def strict_match_mime_type(supported: list[str] | str, header: str) -> Optional[ supported = [s for s in supported if s.strip() and "/" in s] + if len(supported) == 0: + # Default to common types if none are specified + supported = ["audio/*", "video/webm"] + match = mimeparse.best_match(supported, header) if not match: return None