From 117a6c59102045d0250183fb4d947817617d9f2d Mon Sep 17 00:00:00 2001 From: John Gebbie Date: Sat, 3 Sep 2022 13:02:48 +0100 Subject: [PATCH] New package: vosk-api-0.3.43 --- srcpkgs/vosk-api/patches/openblas.diff | 55 ++++++++++++++++++ srcpkgs/vosk-api/template | 78 ++++++++++++++++++++++++++ srcpkgs/vosk-model-small-en-us | 1 + 3 files changed, 134 insertions(+) create mode 100644 srcpkgs/vosk-api/patches/openblas.diff create mode 100644 srcpkgs/vosk-api/template create mode 120000 srcpkgs/vosk-model-small-en-us diff --git a/srcpkgs/vosk-api/patches/openblas.diff b/srcpkgs/vosk-api/patches/openblas.diff new file mode 100644 index 000000000000..4ae3aac80393 --- /dev/null +++ b/srcpkgs/vosk-api/patches/openblas.diff @@ -0,0 +1,55 @@ +--- a/src/matrix/cblas-wrappers.h ++++ b/src/matrix/cblas-wrappers.h +@@ -383,10 +383,10 @@ inline void mul_elements( + // add clapack here + #if !defined(HAVE_ATLAS) + inline void clapack_Xtptri(KaldiBlasInt *num_rows, float *Mdata, KaldiBlasInt *result) { +- stptri_(const_cast("U"), const_cast("N"), num_rows, Mdata, result); ++ stptri_(const_cast("U"), const_cast("N"), num_rows, Mdata, result, 1, 1); + } + inline void clapack_Xtptri(KaldiBlasInt *num_rows, double *Mdata, KaldiBlasInt *result) { +- dtptri_(const_cast("U"), const_cast("N"), num_rows, Mdata, result); ++ dtptri_(const_cast("U"), const_cast("N"), num_rows, Mdata, result, 1, 1); + } + // + inline void clapack_Xgetrf2(KaldiBlasInt *num_rows, KaldiBlasInt *num_cols, +@@ -420,7 +420,7 @@ inline void clapack_Xgesvd(char *v, char *u, KaldiBlasInt *num_cols, + sgesvd_(v, u, + num_cols, num_rows, Mdata, stride, + sv, Vdata, vstride, Udata, ustride, +- p_work, l_work, result); ++ p_work, l_work, result, 1, 1); + } + inline void clapack_Xgesvd(char *v, char *u, KaldiBlasInt *num_cols, + KaldiBlasInt *num_rows, double *Mdata, KaldiBlasInt *stride, +@@ -430,25 +430,25 @@ inline void clapack_Xgesvd(char *v, char *u, KaldiBlasInt *num_cols, + dgesvd_(v, u, + num_cols, num_rows, Mdata, stride, + sv, Vdata, vstride, Udata, ustride, +- p_work, l_work, result); ++ p_work, l_work, result, 1, 1); + } + // + void inline clapack_Xsptri(KaldiBlasInt *num_rows, float *Mdata, + KaldiBlasInt *ipiv, float *work, KaldiBlasInt *result) { +- ssptri_(const_cast("U"), num_rows, Mdata, ipiv, work, result); ++ ssptri_(const_cast("U"), num_rows, Mdata, ipiv, work, result, 1); + } + void inline clapack_Xsptri(KaldiBlasInt *num_rows, double *Mdata, + KaldiBlasInt *ipiv, double *work, KaldiBlasInt *result) { +- dsptri_(const_cast("U"), num_rows, Mdata, ipiv, work, result); ++ dsptri_(const_cast("U"), num_rows, Mdata, ipiv, work, result, 1); + } + // + void inline clapack_Xsptrf(KaldiBlasInt *num_rows, float *Mdata, + KaldiBlasInt *ipiv, KaldiBlasInt *result) { +- ssptrf_(const_cast("U"), num_rows, Mdata, ipiv, result); ++ ssptrf_(const_cast("U"), num_rows, Mdata, ipiv, result, 1); + } + void inline clapack_Xsptrf(KaldiBlasInt *num_rows, double *Mdata, + KaldiBlasInt *ipiv, KaldiBlasInt *result) { +- dsptrf_(const_cast("U"), num_rows, Mdata, ipiv, result); ++ dsptrf_(const_cast("U"), num_rows, Mdata, ipiv, result, 1); + } + #else + inline void clapack_Xgetrf(MatrixIndexT num_rows, MatrixIndexT num_cols, diff --git a/srcpkgs/vosk-api/template b/srcpkgs/vosk-api/template new file mode 100644 index 000000000000..e74d7f4214b0 --- /dev/null +++ b/srcpkgs/vosk-api/template @@ -0,0 +1,78 @@ +# Template file for 'vosk-api' +pkgname=vosk-api +version=0.3.43 +revision=1 +_openblas_ver=0.3.20 +_clapack_ver=3.2.1 +_openfst_commit=7dfd808194105162f20084bb4d8e4ee4b65266d5 +_kaldi_commit=76cd51d44c0a61e3905c35cadb2ec5f54f3e42d1 +build_style="gnu-makefile" +make_use_env=yes +make_build_args="-C src KALDI_ROOT=../../kaldi-${_kaldi_commit} + OPENFST_ROOT=../../kaldi-${_kaldi_commit}/tools/openfst + OPENBLAS_ROOT=../../kaldi-${_kaldi_commit}/tools/OpenBLAS/install" +hostmakedepends="autoconf automake cmake libtool" +makedepends="openblas-devel" +short_desc="Offline speech recognition toolkit" +maintainer="John Gebbie " +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/clapack/archive/v${_clapack_ver}/clapack-${_clapack_ver}.tar.gz +https://github.com/alphacep/kaldi/archive/$_kaldi_commit.tar.gz +https://github.com/alphacep/openfst/archive/$_openfst_commit.tar.gz +https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip" +checksum="50fa82bfbfe3fc5be868237c84ac180eb55da0b65b1803bf022899673afda024 +8d8ff8259454cae392bb58bc4971fef1db632c9fb5cdf61255cd495bd6d6ac4d +4f50b51d0596970b0c1e1356c6a3e791810d1fbc75f2024cd30e818b7b299382 +a7bac90acb9a12fdfe50c240c9bb730a7bcb5c3b3ac32017c4d27177b059680a +30f26242c4eb449f948e42cb302dd7a686cb29a3423a8367f99ff41780942498" +patch_args="-Np1 ../kaldi-${_kaldi_commit}/src/matrix/cblas-wrappers.h" + +pre_build() { + cd "${XBPS_BUILDDIR}" + + mkdir -p "kaldi-${_kaldi_commit}/tools/OpenBLAS/install/lib" + ln -sf /usr/include/openblas "kaldi-${_kaldi_commit}/tools/OpenBLAS/install/include" + ln -sf /usr/lib/libopenblas.a "kaldi-${_kaldi_commit}/tools/OpenBLAS/install/lib" + + ln -sf "../../clapack-${_clapack_ver}" "kaldi-${_kaldi_commit}/tools/clapack" + ln -sf "../../openfst-${_openfst_commit}" "kaldi-${_kaldi_commit}/tools/openfst" + autoreconf -fi "openfst-${_openfst_commit}" + + cmake -S "clapack-${_clapack_ver}" -B "build-clapack-${_clapack_ver}" + make -C "build-clapack-${_clapack_ver}/F2CLIBS" + make -C "build-clapack-${_clapack_ver}/BLAS" + make -C "build-clapack-${_clapack_ver}/SRC" + find "build-clapack-${_clapack_ver}" -name "*.a" | xargs cp -t "${XBPS_BUILDDIR}/kaldi-${_kaldi_commit}/tools/OpenBLAS/install/lib" + + cd "${XBPS_BUILDDIR}/openfst-${_openfst_commit}" + ./configure \ + --prefix="${XBPS_BUILDDIR}/kaldi-${_kaldi_commit}/tools/openfst" \ + --enable-static \ + --enable-shared \ + --enable-far \ + --enable-ngram-fsts \ + --enable-lookahead-fsts \ + --with-pic \ + --disable-bin + make + make install + + cd "${XBPS_BUILDDIR}/kaldi-${_kaldi_commit}/src" + ./configure --mathlib=OPENBLAS_CLAPACK --shared --use-cuda=no + make online2 lm rnnlm +} + +do_install() { + vinstall src/vosk_api.h 644 usr/include + vinstall src/libvosk.so 644 usr/lib +} + +vosk-model-small-en-us_package() { + short_desc="Lightweight english language model" + pkg_install() { + vmkdir usr/share/vosk-models + mv "${XBPS_BUILDDIR}/vosk-model-small-en-us-0.15" "${PKGDESTDIR}/usr/share/vosk-models/small-en-us" + } +} diff --git a/srcpkgs/vosk-model-small-en-us b/srcpkgs/vosk-model-small-en-us new file mode 120000 index 000000000000..db9953d33676 --- /dev/null +++ b/srcpkgs/vosk-model-small-en-us @@ -0,0 +1 @@ +vosk-api \ No newline at end of file