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"] 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) 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