Skip to content

Commit

Permalink
Only show "diarize" option when HF_TOKEN is supplied
Browse files Browse the repository at this point in the history
Fixed Docker caching issues
Updated Readme
  • Loading branch information
Dennis Döring committed Oct 15, 2023
1 parent ae8b2f1 commit d545e5e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ COPY --from=swagger-ui /usr/share/nginx/html/swagger-ui-bundle.js swagger-ui-ass
RUN poetry config virtualenvs.in-project true
RUN poetry install

RUN $POETRY_VENV/bin/pip install pandas transformers nltk pyannote.audio
RUN /app/.venv/bin/pip install pandas transformers nltk pyannote.audio
RUN git clone --depth 1 https://github.com/m-bain/whisperX.git \
&& cd whisperX \
&& $POETRY_VENV/bin/pip install -e .
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
python${PYTHON_VERSION}-venv \
python3-pip \
ffmpeg \
git \
git \
&& rm -rf /var/lib/apt/lists/*

RUN ln -s -f /usr/bin/python${PYTHON_VERSION} /usr/bin/python3 && \
Expand All @@ -36,7 +36,7 @@ COPY --from=swagger-ui /usr/share/nginx/html/swagger-ui.css swagger-ui-assets/sw
COPY --from=swagger-ui /usr/share/nginx/html/swagger-ui-bundle.js swagger-ui-assets/swagger-ui-bundle.js

RUN poetry install
RUN $POETRY_VENV/bin/pip install torch torchaudio pandas transformers nltk pyannote.audio \
RUN /app/.venv/bin/pip install torch torchaudio pandas transformers nltk pyannote.audio \
--index-url https://download.pytorch.org/whl/cu118 \
--index-url https://pypi.org/simple/

Expand All @@ -45,4 +45,4 @@ RUN git clone --depth 1 https://github.com/m-bain/whisperX.git \
&& $POETRY_VENV/bin/pip install --no-dependencies -e .

EXPOSE 9000
CMD gunicorn --bind 0.0.0.0:9000 --workers 1 --timeout 0 app.webservice:app -k uvicorn.workers.UvicornWorker
CMD gunicorn --bind 0.0.0.0:9000 --workers 1 --timeout 0 app.webservice:app -k uvicorn.workers.UvicornWorker
4 changes: 3 additions & 1 deletion app/webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from whisper import tokenizer

ASR_ENGINE = os.getenv("ASR_ENGINE", "openai_whisper")
HF_TOKEN = os.getenv("HF_TOKEN", "")

if ASR_ENGINE == "faster_whisper":
from .faster_whisper.core import transcribe, language_detection
elif ASR_ENGINE == "whisperx":
Expand Down Expand Up @@ -76,7 +78,7 @@ def asr(
diarize : bool = Query(
default=False,
description="Diarize the input",
include_in_schema=(True if ASR_ENGINE == "whisperx" else False)),
include_in_schema=(True if ASR_ENGINE == "whisperx" and HF_TOKEN != "" else False)),
min_speakers : Union[int, None] = Query(
default=None,
description="Min speakers in this file",
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Current release (v1.2.0) supports following whisper models:

- [openai/whisper](https://github.com/openai/whisper)@[v20230918](https://github.com/openai/whisper/releases/tag/v20230918)
- [guillaumekln/faster-whisper](https://github.com/guillaumekln/faster-whisper)@[0.9.0](https://github.com/guillaumekln/faster-whisper/releases/tag/v0.9.0)
- [whisperX](https://github.com/m-bain/whisperX)@[v3.1.1](https://github.com/m-bain/whisperX/releases/tag/v3.1.1)

## Quick Usage

Expand Down

0 comments on commit d545e5e

Please sign in to comment.