build script

master
Bel LaPointe 2022-11-14 08:29:24 -07:00
parent 4453fed962
commit 1c2bf79563
2 changed files with 72 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
**/*.sw*
snowboy-2022/snowboy
**/*.git.d

71
snowboy-2022/build.sh Normal file
View File

@ -0,0 +1,71 @@
#! /bin/bash
echo https://github.com/seasalt-ai/snowboy
cd "$(dirname "$(realpath "$BASH_SOURCE")")"
set -e
set -o pipefail
if [ ! -d ./snowboy ]; then
git clone https://github.com/seasalt-ai/snowboy snowboy.git.d
fi
timeout 2 docker version &> /dev/null
if ! docker images | grep snowboy-pmdl.*latest &> /dev/null; then
pushd snowboy.git.d
docker build -t snowboy-pmdl:latest .
popd
fi
if [ -n "$TRAIN" ] || [ ! -d ./model ] || [ ! -f ./model/hotword.pmdl ]; then
mkdir -p model
pushd model
echo "record 3 instances of your hotword" >&2
for i in 1 2 3; do
read -p "ready? ctrl-c when done"
rec \
-r 16000 \
-c 1 \
-b 16 \
-e signed-integer \
-t wav \
record$i.wav
done
popd
docker run \
--rm \
-it \
-v "$(realpath ./model)":/snowboy-master/examples/Python/model \
snowboy-pmdl:latest
fi
if false; then
if ! which swig; then
brew install swig
fi
pip3 install pyaudio
pushd snowboy.git.d/swig/Python3/
make
popd
cd snowboy.git.d/examples/Python3/
echo '
import snowboydecoder
import datetime
detected_callback = lambda *args: print(datetime.datetime.now(), "GOTCHA")
d = snowboydecoder.HotwordDetector("../../../model/hotword.pmdl", sensitivity=0.5, audio_gain=1)
d.start(detected_callback)
' > breel.py
echo GO
cleanup() {
echo OK IM DONE NOW
}
trap cleanup EXIT
python3 ./breel.py
else
resources="$(realpath snowboy.git.d/resources/common.res)"
hotword="$(realpath ./model/hotword.pmdl)"
go build -o snowboy
./snowboy -model "$hotword" -resources "$resources" -sensitivity 0.4
fi