From b1d887c837bb2ea896e60f3494098ba71a0a07fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryan=20Pers=C3=A9e?= <98691129+rpersee@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:44:48 +0200 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20build=20error=20-=20=E2=80=98sort?= =?UTF-8?q?=E2=80=99=20is=20not=20a=20member=20of=20=E2=80=98std=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/profiler.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/profiler.cc b/lib/profiler.cc index 1fa073b..18f92ca 100644 --- a/lib/profiler.cc +++ b/lib/profiler.cc @@ -1,5 +1,6 @@ #include "profiler.h" +#include #include #include #include From bfa6bb917c5f7fbfe982012a4a237c2387130349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryan=20Pers=C3=A9e?= <98691129+rpersee@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:46:50 +0200 Subject: [PATCH 2/3] feat: Containerize useful_transformers demo --- Dockerfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0c0a02b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM python:3.9-slim AS builder + +WORKDIR /build + +# Install system build dependencies +RUN apt-get update && apt-get install -y build-essential + +# Install Python build dependencies +RUN pip install pybind11[global] + +# Copy application code +COPY . . + +# Build project's wheels +RUN pip wheel --no-cache-dir --wheel-dir=/wheels -e . + + +FROM python:3.9-slim + +WORKDIR /app + +# Install required libraries +RUN apt-get update && apt-get install -y libgomp1 && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install the application +RUN --mount=type=bind,from=builder,source=/wheels,target=/wheels \ + pip install --no-cache-dir --no-index --find-links=/wheels useful_transformers + +# Set the application as the entrypoint +ENTRYPOINT ["taskset", "-c", "4-7", "python", "-m", "useful_transformers.transcribe_wav"] From 67228932829c434afdf168a2a063d0fdcad1c5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryan=20Pers=C3=A9e?= <98691129+rpersee@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:55:36 +0200 Subject: [PATCH 3/3] docs: Try transcription in Docker --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 2dd8bf1..ed46e6c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,22 @@ If you don't have a wav file handy, running the above command will transcribe an $ taskset -c 4-7 python -m useful_transformers.transcribe_wav Ever tried, ever failed. No matter, try again. Fail again. Fail better. +### Try in Docker + +You can also run the transcription in Docker with: +```bash +$ docker build -t useful-transformers . +$ docker run --rm -t \ + --device /dev/dri:/dev/dri \ + -v "$(PWD)":/work useful-transformers \ + /work/ +``` + +> **Note:** You can use `ffmpeg` to convert your audio file to a mono WAV file with a sample rate of 16 kHz: +> ```bash +> ffmpeg -i -ac 1 -ar 16000 -f wav +> ``` + ## Performance ![Performance comparison](https://github.com/usefulsensors/useful-transformers/blob/main/examples/whisper/assets/perf-comparison.png)