Skip to content

Commit 4ab917c

Browse files
committed
fix/refac: stt default content type
1 parent 7f0ca8c commit 4ab917c

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

backend/open_webui/routers/audio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,10 +1151,9 @@ def transcription(
11511151
user=Depends(get_verified_user),
11521152
):
11531153
log.info(f"file.content_type: {file.content_type}")
1154-
11551154
stt_supported_content_types = getattr(
11561155
request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", []
1157-
) or ["audio/*", "video/webm"]
1156+
)
11581157

11591158
if not strict_match_mime_type(stt_supported_content_types, file.content_type):
11601159
raise HTTPException(

backend/open_webui/routers/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def process_uploaded_file(request, file, file_path, file_item, file_metadata, us
114114
if file.content_type:
115115
stt_supported_content_types = getattr(
116116
request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", []
117-
) or ["audio/*", "video/webm"]
117+
)
118118

119119
if strict_match_mime_type(stt_supported_content_types, file.content_type):
120120
file_path = Storage.get_file(file_path)

backend/open_webui/utils/misc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,10 @@ def strict_match_mime_type(supported: list[str] | str, header: str) -> Optional[
622622

623623
supported = [s for s in supported if s.strip() and "/" in s]
624624

625+
if len(supported) == 0:
626+
# Default to common types if none are specified
627+
supported = ["audio/*", "video/webm"]
628+
625629
match = mimeparse.best_match(supported, header)
626630
if not match:
627631
return None

0 commit comments

Comments
 (0)