# Template file for 'vosk-api' pkgname=vosk-api version=0.3.45 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=93ef0019b847272a239fbb485ef97f29feb1d587 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="Orphaned " 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="930fb9cfa6c1b3035d3730feee7d670fb893caa0c71bd2159ee7623102674c26 f47a996af546884a8e1cb961323b796c5c238c1bbeabaf657bb300b760e431b2 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 } }