From 6186bbf337b4358f7a0f0baa6b18806b845a3b38 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 18 Jun 2025 14:01:14 +0400 Subject: [PATCH] refac/fix: stt supported type --- backend/open_webui/routers/audio.py | 14 +++++++++----- backend/open_webui/routers/files.py | 15 ++++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/backend/open_webui/routers/audio.py b/backend/open_webui/routers/audio.py index 6baaa589d..211f2ae85 100644 --- a/backend/open_webui/routers/audio.py +++ b/backend/open_webui/routers/audio.py @@ -920,14 +920,18 @@ def transcription( ): log.info(f"file.content_type: {file.content_type}") - supported_content_types = request.app.state.config.STT_SUPPORTED_CONTENT_TYPES or [ - "audio/*", - "video/webm", - ] + stt_supported_content_types = getattr( + request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", [] + ) if not any( fnmatch(file.content_type, content_type) - for content_type in supported_content_types + for content_type in ( + stt_supported_content_types + if stt_supported_content_types + and any(t.strip() for t in stt_supported_content_types) + else ["audio/*", "video/webm"] + ) ): raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, diff --git a/backend/open_webui/routers/files.py b/backend/open_webui/routers/files.py index b9bb15c7b..bdf5780fc 100644 --- a/backend/open_webui/routers/files.py +++ b/backend/open_webui/routers/files.py @@ -155,17 +155,18 @@ def upload_file( if process: try: if file.content_type: - stt_supported_content_types = ( - request.app.state.config.STT_SUPPORTED_CONTENT_TYPES - or [ - "audio/*", - "video/webm", - ] + stt_supported_content_types = getattr( + request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", [] ) if any( fnmatch(file.content_type, content_type) - for content_type in stt_supported_content_types + for content_type in ( + stt_supported_content_types + if stt_supported_content_types + and any(t.strip() for t in stt_supported_content_types) + else ["audio/*", "video/webm"] + ) ): file_path = Storage.get_file(file_path) result = transcribe(request, file_path, file_metadata)