74 lines
2.5 KiB
Bash
74 lines
2.5 KiB
Bash
|
# Template file for 'vosk-api'
|
||
|
pkgname=vosk-api
|
||
|
version=0.3.43
|
||
|
revision=1
|
||
|
create_wrksrc=yes
|
||
|
build_wrksrc="vosk-api-${version}/src"
|
||
|
# Vosk is built with their own vendored version of Kaldi which has no releases
|
||
|
# of its own, so the commit must be determined by the date of the vosk release.
|
||
|
_kaldi_commit=ecb4b47159501ef0d67888633e65b8fc0c1f79d1
|
||
|
build_style=gnu-makefile
|
||
|
make_use_env=yes
|
||
|
make_build_args="KALDI_ROOT=../../kaldi HAVE_OPENBLAS_NO_F2C=1 HAVE_OPENBLAS_CLAPACK=0"
|
||
|
makedepends="blas-devel lapack-devel openblas-devel libgomp-devel openfst-devel"
|
||
|
short_desc="Offline speech recognition toolkit"
|
||
|
maintainer="John Gebbie <me@johngebbie.com>"
|
||
|
license="Apache-2.0"
|
||
|
homepage="https://alphacephei.com/vosk"
|
||
|
distfiles="https://github.com/alphacep/vosk-api/archive/v${version}/vosk-api-${version}.tar.gz
|
||
|
https://github.com/alphacep/kaldi/archive/${_kaldi_commit}.tar.gz
|
||
|
https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip"
|
||
|
checksum="50fa82bfbfe3fc5be868237c84ac180eb55da0b65b1803bf022899673afda024
|
||
|
39cadd5a351a5513e3e4e1f71ac4b4f018a592a856a55f1d32c159e22e799f64
|
||
|
30f26242c4eb449f948e42cb302dd7a686cb29a3423a8367f99ff41780942498"
|
||
|
shlib_provides="libvosk.so"
|
||
|
patch_args="-Np1 -d ${pkgname}-${version}"
|
||
|
|
||
|
if [ "$XBPS_TARGET_LIBC" = musl ]; then
|
||
|
makedepends+=" libexecinfo-devel"
|
||
|
fi
|
||
|
|
||
|
post_extract() {
|
||
|
mv "kaldi-${_kaldi_commit}" kaldi
|
||
|
cd "${wrksrc}/kaldi/tools"
|
||
|
mkdir -p OpenBLAS/install/lib
|
||
|
ln -sf "${XBPS_CROSS_BASE}/usr/include/openblas" OpenBLAS/install/include
|
||
|
ln -sf "${XBPS_CROSS_BASE}/usr/lib/"* OpenBLAS/install/lib
|
||
|
mkdir -p openfst/include openfst/lib
|
||
|
ln -sf "${XBPS_CROSS_BASE}/usr/include/fst" openfst/include
|
||
|
ln -sf "${XBPS_CROSS_BASE}/usr/lib/"* openfst/lib
|
||
|
}
|
||
|
|
||
|
pre_build() {
|
||
|
cd "${wrksrc}/kaldi/src"
|
||
|
./configure ${CROSS_BUILD:+--host="${XBPS_CROSS_TRIPLET}"} --mathlib=OPENBLAS_NO_F2C --shared --use-cuda=no
|
||
|
make online2 lm rnnlm
|
||
|
}
|
||
|
|
||
|
do_install() {
|
||
|
vinstall vosk_api.h 644 usr/include
|
||
|
vinstall libvosk.so 644 usr/lib
|
||
|
|
||
|
vmkdir usr/share/vosk-models
|
||
|
mv "${wrksrc}/vosk-model-small-en-us-0.15" "${DESTDIR}/usr/share/vosk-models/small-en-us"
|
||
|
}
|
||
|
|
||
|
do_check() {
|
||
|
cd "${wrksrc}/vosk-api-${version}/c"
|
||
|
ln -sf "${wrksrc}/vosk-model-small-en-us-0.15" model
|
||
|
ln -sf ../python/example/test.wav .
|
||
|
ldflags="-fopenmp -L../src -lvosk -ldl -lpthread -Wl,-rpath,../src"
|
||
|
if [ "$XBPS_TARGET_LIBC" = musl ]; then
|
||
|
ldflags+=" -lexecinfo"
|
||
|
fi
|
||
|
make LDFLAGS="$ldflags"
|
||
|
./test_vosk | grep -q '"text" : "zero one eight zero three"'
|
||
|
}
|
||
|
|
||
|
vosk-model-small-en-us_package() {
|
||
|
short_desc="Lightweight english language model"
|
||
|
pkg_install() {
|
||
|
vmove usr/share/vosk-models
|
||
|
}
|
||
|
}
|