From 3e9a730ec39a3642ca2c97fcf340ad4915877aee Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Fri, 4 Oct 2024 15:22:00 -0400 Subject: [PATCH] Add an integration test for whisper (#45) --- ci/docker-compose.yml | 2 ++ ci/run.sh | 2 +- ci/test.sh | 9 +++++++++ examples/whisper/Dockerfile | 2 ++ examples/whisper/cmd.sh | 4 ---- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ci/docker-compose.yml b/ci/docker-compose.yml index 76d4d39..480e4c1 100644 --- a/ci/docker-compose.yml +++ b/ci/docker-compose.yml @@ -11,6 +11,8 @@ services: image: ${DOCKER_REPOSITORY_BASE}-imagemagick:${DOCKER_TAG} tesseract: image: ${DOCKER_REPOSITORY_BASE}-tesseract:${DOCKER_TAG} + whisper: + image: ${DOCKER_REPOSITORY_BASE}-whisper:${DOCKER_TAG} test: image: alpine command: sleep 300 diff --git a/ci/run.sh b/ci/run.sh index 1b217a7..79c7018 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -12,4 +12,4 @@ docker exec ci-test-1 /test.sh echo $? docker compose down 2>&1 > /dev/null -docker compose rm 2>&1 > /dev/null \ No newline at end of file +docker compose rm 2>&1 > /dev/null diff --git a/ci/test.sh b/ci/test.sh index 335dfd5..0b985b0 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -15,6 +15,7 @@ SERVICES=( "imagemagick" "crayfits" "ffmpeg" + "whisper" ) for SERVICE in "${SERVICES[@]}"; do URL="http://$SERVICE:8080/" @@ -58,6 +59,14 @@ for SERVICE in "${SERVICES[@]}"; do grep "One time I was ridin' along on the mule" ocr.txt || exit 1 echo "PDF OCR as expected" rm ocr.txt + elif [ "$SERVICE" == "whisper" ]; then + curl -s -o vtt.txt \ + --header "Accept: text/plain" \ + --header "Apix-Ldp-Resource: https://github.com/ggerganov/whisper.cpp/raw/master/samples/jfk.wav" \ + "$URL" + grep "ask not what your country can do for you" vtt.txt || exit 1 + echo "VTT as expected" + rm vtt.txt else echo "Unknown service" exit 1 diff --git a/examples/whisper/Dockerfile b/examples/whisper/Dockerfile index 1340dfe..4d10d46 100644 --- a/examples/whisper/Dockerfile +++ b/examples/whisper/Dockerfile @@ -7,6 +7,8 @@ COPY --from=scyllaridae /app /app COPY scyllaridae.yml /app COPY cmd.sh /app +RUN bash ./models/download-ggml-model.sh medium.en + RUN apt-get update && apt-get install -y gosu=1.14-1 --no-install-recommends \ && rm -rf /var/lib/apt/lists/* \ && groupadd -r nobody \ diff --git a/examples/whisper/cmd.sh b/examples/whisper/cmd.sh index a4c7c74..e710b63 100755 --- a/examples/whisper/cmd.sh +++ b/examples/whisper/cmd.sh @@ -4,10 +4,6 @@ set -eou pipefail -if [ ! -f /app/models/ggml-medium.en.bin ]; then - bash ./models/download-ggml-model.sh medium.en > /dev/null 2>&1 -fi - # take stdin and buffer it into a temp file input_temp=$(mktemp /tmp/whisper-input-XXXXXX) cat > "$input_temp"