+whisper.cpp (#1276)

Co-authored-by: Max Howell <mxcl@me.com>
This commit is contained in:
Sanchit Ram Arvind 2023-05-04 15:49:17 -05:00 committed by GitHub
parent 86bead534f
commit ea39f209ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 106 additions and 0 deletions

View file

@ -0,0 +1,12 @@
diff --git a/Makefile b/Makefile
index c452b88..6bf34b3 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,6 @@ endif
# feel free to update the Makefile for your architecture and send a pull request or issue
ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 i686))
ifeq ($(UNAME_S),Darwin)
- CFLAGS += -mf16c
AVX1_M := $(shell sysctl machdep.cpu.features)
ifneq (,$(findstring FMA,$(AVX1_M)))
CFLAGS += -mfma

View file

@ -0,0 +1,45 @@
distributable:
url: https://github.com/ggerganov/whisper.cpp/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: ggerganov/whisper.cpp
platforms:
- darwin/aarch64
- linux
provides:
- bin/whisper.cpp
dependencies:
gnu.org/wget: '*'
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
freedesktop.org/pkg-config: ~0.29
libsdl.org: '*'
gnu.org/patch: '*'
script: |
patch -p1 < props/illegal_instruction.patch
make --jobs {{ hw.concurrency }}
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/*
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
test:
dependencies:
curl.se: '*'
script: |
curl -LO https://github.com/ggerganov/whisper.cpp/raw/master/samples/jfk.wav
whisper.cpp -f jfk.wav --print-colors

View file

@ -0,0 +1,17 @@
#!/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

@ -0,0 +1,32 @@
#!/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