mirror of
https://github.com/open-webui/open-webui
synced 2024-11-07 00:59:52 +00:00
refac
This commit is contained in:
parent
3899405864
commit
1c4b6b9cd9
@ -493,18 +493,17 @@ def transcription(
|
|||||||
if (
|
if (
|
||||||
os.path.getsize(file_path) > MAX_FILE_SIZE
|
os.path.getsize(file_path) > MAX_FILE_SIZE
|
||||||
): # Still larger than 25MB after compression
|
): # Still larger than 25MB after compression
|
||||||
chunks = split_on_silence(
|
log.debug(
|
||||||
audio, min_silence_len=1000, silence_thresh=-40
|
f"Compressed file size is still larger than {MAX_FILE_SIZE_MB}MB: {os.path.getsize(file_path)}"
|
||||||
)
|
)
|
||||||
texts = []
|
raise HTTPException(
|
||||||
for i, chunk in enumerate(chunks):
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
chunk_file_path = f"{file_dir}/{id}_chunk{i}.{ext}"
|
detail=ERROR_MESSAGES.FILE_TOO_LARGE(
|
||||||
chunk.export(chunk_file_path, format=ext)
|
size=f"{MAX_FILE_SIZE_MB}MB"
|
||||||
text = transcribe(chunk_file_path)
|
),
|
||||||
texts.append(text)
|
)
|
||||||
data = {"text": " ".join(texts)}
|
|
||||||
else:
|
data = transcribe(file_path)
|
||||||
data = transcribe(file_path)
|
|
||||||
else:
|
else:
|
||||||
data = transcribe(file_path)
|
data = transcribe(file_path)
|
||||||
|
|
||||||
|
@ -90,6 +90,10 @@ class ERROR_MESSAGES(str, Enum):
|
|||||||
"The Ollama API is disabled. Please enable it to use this feature."
|
"The Ollama API is disabled. Please enable it to use this feature."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
FILE_TOO_LARGE = (
|
||||||
|
lambda size="": f"Oops! The file you're trying to upload is too large. Please upload a file that is less than {size}."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TASKS(str, Enum):
|
class TASKS(str, Enum):
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user