Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we have a 16kHZ WAV file #41

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/whisper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y gosu=1.14-1 --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd -r nobody \
&& useradd -r -g nobody scyllaridae \
&& chmod +x /app/docker-entrypoint.sh /app/cmd.sh
&& chmod +x /app/docker-entrypoint.sh /app/cmd.sh \
&& chown scyllaridae /app/models

ENTRYPOINT ["/app/docker-entrypoint.sh"]
25 changes: 19 additions & 6 deletions examples/whisper/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,32 @@
set -eou pipefail

if [ ! -f /app/models/ggml-medium.en.bin ]; then
bash ./models/download-ggml-model.sh medium.en
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"

# make sure we have a 16kHz WAV file
output_file="${input_temp}_16khz.wav"
ffmpeg -hide_banner -loglevel error -i "$input_temp" -ar 16000 -ac 1 "$output_file"

# generate the VTT file
/app/main \
-m /app/models/ggml-medium.en.bin \
--output-vtt \
-f "$input_temp" \
--output-file "$input_temp" > /dev/null 2>&1
-f "$output_file" \
--output-file "$input_temp" > /dev/null 2>&1 || true

cat "$input_temp.vtt"
# make sure a VTT file was created
STATUS=$(head -1 "$input_temp.vtt" | grep WEBVTT || echo "FAIL")
if [ "$STATUS" != "FAIL" ]; then
cat "$input_temp.vtt"
fi

rm "$input_temp" "$input_temp.vtt"
rm "$input_temp" "$input_temp.vtt" "$output_file"

if [ "$STATUS" == "FAIL" ]; then
exit 1
fi
Loading