### this file is sourced not run
PKGVER=2023.09.10 # pull date
PKGBUILD=1
PKGARCH=x86_64

# source: james
TARBALL=whisper-cpp-$PKGVER.tar.gz
MD5SUM=3b9c3b57d0e0555ee2173cf7c4c420d0
SRC_URL=https://github.com/ggerganov/whisper.cpp/archive/6ddc727fac7a24facdd2810f7094ae1dd141b5cc.tar.gz
BUNDLE=

SLACKREQ='libSDL2 libopenblas'
SLACKDESC="whisper-cpp: whisper-cpp $PKGVER (Speech to text)
whisper-cpp: 
whisper-cpp: whisper.cpp is a high-performance, plain C/C++ inference engine using 
whisper-cpp: OpenAI's Whisper automatic speech recognition (ASR) model.
whisper-cpp:
whisper-cpp: Package installs to /opt/whisper-cpp. It includes English-only 'base'
whisper-cpp: model, larger/better models can be downloaded using download-ggml-model.sh
whisper-cpp: from the model subdirectory.
whisper-cpp: 
whisper-cpp: https://github.com/ggerganov/whisper.cpp
whisper-cpp: 
"

DEFAULT_MODEL=base.en # tiny/tiny.en/base/base.en/small/small.en/medium/medium.en/large/large.en

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/whisper* &&
	bash ./models/download-ggml-model.sh $DEFAULT_MODEL &&
	true
}

### default pkg_package
### build
pkg_build() {
	#export WHISPER_CLBLAST=1 # accelerate with OpenCL
	#export WHISPER_CUBLAST=1 # accelerate with nvidia CUDA
	export WHISPER_OPENBLAS=1 && # accelerate with openblas

	# build
	cd /tmp/whisper* &&	
	make default command stream &&

	# install
	install -dm755 /opt/whisper-cpp/examples &&
	install -m755 main quantize stream command /opt/whisper-cpp &&
	install -m755 examples/*.sh /opt/whisper-cpp/examples &&
	install -m644 README* LICENSE /opt/whisper-cpp &&
	cp -r models samples /opt/whisper-cpp &&	
	
	pkg_build_slackdesc
}
