diff --git a/Dockerfile b/Dockerfile index 6687a67fd..010dbc869 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,10 @@ ENV WEBUI_SECRET_KEY "" ENV SCARF_NO_ANALYTICS true ENV DO_NOT_TRACK true +#Whisper TTS Settings +ENV WHISPER_DIR="/app/backend/data/cache/whisper/models" +ENV WHISPER_MODEL="base" + WORKDIR /app/backend # install python dependencies @@ -45,6 +49,8 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('all-MiniLM-L6-v2')" +RUN python -c "import os; from faster_whisper import WhisperModel; WhisperModel(os.environ['WHISPER_MODEL'], device='cpu', compute_type='int8', download_root=os.environ['WHISPER_DIR'])" + # copy embedding weight from build RUN mkdir -p /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2 diff --git a/backend/apps/audio/main.py b/backend/apps/audio/main.py index c03aaf37a..85937de80 100644 --- a/backend/apps/audio/main.py +++ b/backend/apps/audio/main.py @@ -1,3 +1,4 @@ +import os from fastapi import ( FastAPI, Request, @@ -53,12 +54,14 @@ def transcribe( f.write(contents) f.close() - model_name = WHISPER_MODEL_NAME + model_name = os.getenv('WHISPER_MODEL', WHISPER_MODEL_NAME) + download_root = os.getenv('WHISPER_DIR', f"{CACHE_DIR}/whisper/models") + model = WhisperModel( model_name, device="cpu", compute_type="int8", - download_root=f"{CACHE_DIR}/whisper/models", + download_root=download_root, ) segments, info = model.transcribe(file_path, beam_size=5)