fix whisper.cpp metal; remove helpers

Trying to standardize on huggingface-cli downloads the models and ScriptHub scripts or endpoints make use of that.
This commit is contained in:
Max Howell 2023-11-21 17:41:31 -05:00
parent 702c0e236a
commit 2c4fedb117
3 changed files with 16 additions and 64 deletions

View file

@ -13,13 +13,13 @@ provides:
- bin/whisper.cpp
dependencies:
gnu.org/wget: '*'
libsdl.org: '*'
build:
dependencies:
freedesktop.org/pkg-config: ~0.29
gnu.org/patch: '*'
gnu.org/coreutils: '*'
script:
- run: patch -p1 < props/illegal_instruction.patch
if: <1.4.3
@ -28,21 +28,22 @@ build:
- make stream --jobs {{ hw.concurrency }}
- make command --jobs {{ hw.concurrency }}
- mkdir -p {{prefix}}/bin {{prefix}}/tbin {{prefix}}/share
- mv main stream command {{prefix}}/tbin
- chmod +x {{prefix}}/tbin/*
# ggml-metal.metal must be installed alongside whisper.cpp sadly
- install -Dt {{prefix}}/bin
ggml-metal.metal
stream command
models/download-ggml-model.sh
- mv models/download-ggml-model.sh {{prefix}}/tbin/download-ggml-model.sh
- mv props/whisper.cpp props/whisper-fetch {{prefix}}/bin
- mv examples/command/commands.txt {{prefix}}/share
env:
darwin/aarch64:
# https://github.com/ggerganov/whisper.cpp/issues/1367
WHISPER_NO_METAL: 1
- install -D main {{prefix}}/bin/whisper.cpp
- install -D examples/command/commands.txt {{prefix}}/share/whisper.cpp/commands.txt
test:
dependencies:
curl.se: '*'
env:
cache: $HOME/.cache/huggingface
script: |
curl -LO https://github.com/ggerganov/whisper.cpp/raw/master/samples/jfk.wav
whisper.cpp -f jfk.wav --print-colors
huggingface-cli download ggerganov/whisper.cpp ggml-base.en.bin
model="$(find "$cache" -name "ggml-base.en.bin")"
curl https://github.com/ggerganov/whisper.cpp/raw/master/samples/jfk.wav | whisper.cpp --model "$model" -
cache:
$HOME/.cache/huggingface

View file

@ -1,17 +0,0 @@
#!/bin/sh
set -e
test -n "$VERBOSE" && set -x
MODEL_NAME="base"
MODEL_DIR="$1"
VERSION="$2"
D="$(cd "$(dirname "$0")"/../tbin && pwd)"
mkdir -p "$MODEL_DIR"
# we have to move the script as it downloads relative to itself
cp "$D/download-ggml-model.sh" "$MODEL_DIR"
bash "$MODEL_DIR/download-ggml-model.sh" "$MODEL_NAME.en"
rm "$MODEL_DIR/download-ggml-model.sh"

View file

@ -1,32 +0,0 @@
#!/bin/sh
set -e
test -n "$VERBOSE" && set -x
D="$(cd "$(dirname "$0")"/.. && pwd)"
VERSION="$(basename "$D")"
MODEL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/models/whisper"
export PATH="$D/tbin:$PATH"
whisper-fetch "$MODEL_DIR" $VERSION
case $1 in
stream)
shift
exec "$D"/tbin/stream \
--model "$MODEL_DIR"/ggml-base.en.bin \
"$@"
;;
command)
shift
exec "$D"/tbin/command \
--model "$MODEL_DIR"/ggml-base.en.bin \
"$@"
;;
*)
exec "$D"/tbin/main \
--model "$MODEL_DIR"/ggml-base.en.bin \
"$@"
;;
esac