forked from open-webui/open-webui
Merge Updates & Dockerfile improvements
This commit is contained in:
parent
fdef2abdfb
commit
9763d885be
155 changed files with 14509 additions and 4803 deletions
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import logging
|
||||
from fastapi import (
|
||||
FastAPI,
|
||||
Request,
|
||||
|
@ -21,11 +22,24 @@ from utils.utils import (
|
|||
)
|
||||
from utils.misc import calculate_sha256
|
||||
|
||||
from config import CACHE_DIR, UPLOAD_DIR, WHISPER_MODEL, WHISPER_MODEL_DIR, DEVICE_TYPE
|
||||
from config import (
|
||||
SRC_LOG_LEVELS,
|
||||
CACHE_DIR,
|
||||
UPLOAD_DIR,
|
||||
WHISPER_MODEL,
|
||||
WHISPER_MODEL_DIR,
|
||||
DEVICE_TYPE,
|
||||
)
|
||||
|
||||
if DEVICE_TYPE != "cuda":
|
||||
log = logging.getLogger(__name__)
|
||||
log.setLevel(SRC_LOG_LEVELS["AUDIO"])
|
||||
|
||||
whisper_device_type = DEVICE_TYPE
|
||||
|
||||
if whisper_device_type != "cuda":
|
||||
whisper_device_type = "cpu"
|
||||
|
||||
log.info(f"whisper_device_type: {whisper_device_type}")
|
||||
|
||||
app = FastAPI()
|
||||
app.add_middleware(
|
||||
|
@ -42,7 +56,7 @@ def transcribe(
|
|||
file: UploadFile = File(...),
|
||||
user=Depends(get_current_user),
|
||||
):
|
||||
print(file.content_type)
|
||||
log.info(f"file.content_type: {file.content_type}")
|
||||
|
||||
if file.content_type not in ["audio/mpeg", "audio/wav"]:
|
||||
raise HTTPException(
|
||||
|
@ -66,7 +80,7 @@ def transcribe(
|
|||
)
|
||||
|
||||
segments, info = model.transcribe(file_path, beam_size=5)
|
||||
print(
|
||||
log.info(
|
||||
"Detected language '%s' with probability %f"
|
||||
% (info.language, info.language_probability)
|
||||
)
|
||||
|
@ -76,7 +90,7 @@ def transcribe(
|
|||
return {"text": transcript.strip()}
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
log.exception(e)
|
||||
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue