mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac/fix: stt supported type
This commit is contained in:
parent
e79f31b9c4
commit
6186bbf337
@ -920,14 +920,18 @@ def transcription(
|
|||||||
):
|
):
|
||||||
log.info(f"file.content_type: {file.content_type}")
|
log.info(f"file.content_type: {file.content_type}")
|
||||||
|
|
||||||
supported_content_types = request.app.state.config.STT_SUPPORTED_CONTENT_TYPES or [
|
stt_supported_content_types = getattr(
|
||||||
"audio/*",
|
request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", []
|
||||||
"video/webm",
|
)
|
||||||
]
|
|
||||||
|
|
||||||
if not any(
|
if not any(
|
||||||
fnmatch(file.content_type, content_type)
|
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(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
|
@ -155,17 +155,18 @@ def upload_file(
|
|||||||
if process:
|
if process:
|
||||||
try:
|
try:
|
||||||
if file.content_type:
|
if file.content_type:
|
||||||
stt_supported_content_types = (
|
stt_supported_content_types = getattr(
|
||||||
request.app.state.config.STT_SUPPORTED_CONTENT_TYPES
|
request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", []
|
||||||
or [
|
|
||||||
"audio/*",
|
|
||||||
"video/webm",
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if any(
|
if any(
|
||||||
fnmatch(file.content_type, content_type)
|
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)
|
file_path = Storage.get_file(file_path)
|
||||||
result = transcribe(request, file_path, file_metadata)
|
result = transcribe(request, file_path, file_metadata)
|
||||||
|
Loading…
Reference in New Issue
Block a user