Github messages for voidlinux
 help / color / mirror / Atom feed
From: JohnGebbie <JohnGebbie@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] New package: vosk-api-0.3.43
Date: Sun, 04 Dec 2022 09:19:44 +0100	[thread overview]
Message-ID: <20221204081944.wuJAHIVLmxGO-PKUKtODBJFaGlzBneNS1bXlS6W12fM@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-39015@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]

There is an updated pull request by JohnGebbie against master on the void-packages repository

https://github.com/JohnGebbie/void-packages libvosk
https://github.com/void-linux/void-packages/pull/39015

New package: vosk-api-0.3.43
#### Testing the changes
- I tested the changes in this PR: **YES**

#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing
- I built this PR locally for my native architecture, (x86_64-glibc)

Closes https://github.com/void-linux/void-packages/issues/39009

This speech recognition library is a dependency of my assistive voice input program (https://github.com/void-linux/void-packages/pull/39716).
The build requires building their forked version of Kaldi which has different dependencies and a different process from the upstream.
I've patched it to use the latest version of openblas that's already packaged, and the latest version of openfst which I've also committed a template for.


A patch file from https://github.com/void-linux/void-packages/pull/39015.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-libvosk-39015.patch --]
[-- Type: text/x-diff, Size: 22676 bytes --]

From c92646ddcc4f683e60de8da6a026baf66b28e004 Mon Sep 17 00:00:00 2001
From: John Gebbie <me@johngebbie.com>
Date: Fri, 28 Oct 2022 17:44:34 +0100
Subject: [PATCH 1/2] New package: openfst-1.8.2

---
 common/shlibs                               |  1 +
 srcpkgs/openfst-devel                       |  1 +
 srcpkgs/openfst/patches/cross-compile.patch | 23 ++++++++++
 srcpkgs/openfst/template                    | 47 +++++++++++++++++++++
 4 files changed, 72 insertions(+)
 create mode 120000 srcpkgs/openfst-devel
 create mode 100644 srcpkgs/openfst/patches/cross-compile.patch
 create mode 100644 srcpkgs/openfst/template

diff --git a/common/shlibs b/common/shlibs
index 8fd417267d4d..fd6908601c80 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4206,3 +4206,4 @@ libtracefs.so.1 libtracefs-1.4.2_1
 libtracecmd.so.1 libtracecmd-3.1.2_1
 libkshark.so.2 libkshark-2.1.1_1
 libcpp-hocon.so.0.3.0 cpp-hocon-0.3.0_5
+libfst.so.25 openfst-1.8.2_1
diff --git a/srcpkgs/openfst-devel b/srcpkgs/openfst-devel
new file mode 120000
index 000000000000..b4e86ac8d61f
--- /dev/null
+++ b/srcpkgs/openfst-devel
@@ -0,0 +1 @@
+openfst
\ No newline at end of file
diff --git a/srcpkgs/openfst/patches/cross-compile.patch b/srcpkgs/openfst/patches/cross-compile.patch
new file mode 100644
index 000000000000..4014f51dba38
--- /dev/null
+++ b/srcpkgs/openfst/patches/cross-compile.patch
@@ -0,0 +1,23 @@
+From 256f83e52112a5cd37e37a34beff2c4f0eae4660 Mon Sep 17 00:00:00 2001
+From: Nickolay Shmyrev <nshmyrev@gmail.com>
+Date: Tue, 16 Jun 2020 15:22:19 +0200
+Subject: [PATCH] Don't fail on cross-compile
+
+---
+ configure.ac | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index d52ed02..0f53b4d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -180,7 +180,8 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([
+               [AC_MSG_FAILURE(m4_normalize([
+                    Test float equality failed!
+                    Compile with -msse -mfpmath=sse if using g++.
+-              ]))])
++              ]))],
++              [echo "Ignoring test for cross-compilation"])
+ 
+ AC_CHECK_LIB([dl], dlopen, [DL_LIBS=-ldl])
+ AC_SUBST([DL_LIBS])
diff --git a/srcpkgs/openfst/template b/srcpkgs/openfst/template
new file mode 100644
index 000000000000..1e62d249f83c
--- /dev/null
+++ b/srcpkgs/openfst/template
@@ -0,0 +1,47 @@
+# Template file for 'openfst'
+pkgname=openfst
+version=1.8.2
+revision=1
+# Limiting archs until resolved why a test fails when natively compiling i686:
+# https://github.com/kaldi-asr/kaldi/issues/4808
+archs="x86_64* aarch64*"
+build_style=gnu-configure
+configure_args="
+	--disable-bin
+	--disable-dependency-tracking
+	--enable-compact-fsts
+	--enable-compress
+	--enable-const-fsts
+	--enable-far
+	--enable-linear-fsts
+	--enable-lookahead-fsts
+	--enable-mpdt
+	--enable-ngram-fsts
+	--enable-pdt
+	--enable-shared
+	--enable-static
+	--with-pic
+"
+hostmakedepends="autoconf automake libtool"
+short_desc="Finite-state transducers library"
+maintainer="John Gebbie <me@johngebbie.com>"
+license="Apache-2.0"
+homepage="https://www.openfst.org"
+distfiles="https://www.openfst.org/twiki/pub/FST/FstDownload/openfst-$version.tar.gz"
+checksum=de987bf3624721c5d5ba321af95751898e4f4bb41c8a36e2d64f0627656d8b42
+
+pre_configure() {
+	autoreconf -fi
+}
+
+openfst-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove "usr/lib/fst/*.a"
+		vmove "usr/lib/fst/*.so"
+	}
+}

From 9a5023eaff12c2002a909d90799d03126f6572a8 Mon Sep 17 00:00:00 2001
From: John Gebbie <me@johngebbie.com>
Date: Fri, 28 Oct 2022 17:57:26 +0100
Subject: [PATCH 2/2] New package: vosk-api-0.3.43

---
 common/shlibs                                 |   1 +
 srcpkgs/vosk-api/patches/kaldi-lapack.patch   |  44 +++++
 .../patches/kaldi-to-openblas-0.3.21.patch    |  55 ++++++
 .../patches/kaldi-to-openfst-1.8.2.patch      | 168 ++++++++++++++++++
 srcpkgs/vosk-api/patches/series               |   0
 srcpkgs/vosk-api/patches/vosk-lapack.patch    |  40 +++++
 srcpkgs/vosk-api/template                     |  78 ++++++++
 srcpkgs/vosk-model-small-en-us                |   1 +
 8 files changed, 387 insertions(+)
 create mode 100644 srcpkgs/vosk-api/patches/kaldi-lapack.patch
 create mode 100644 srcpkgs/vosk-api/patches/kaldi-to-openblas-0.3.21.patch
 create mode 100644 srcpkgs/vosk-api/patches/kaldi-to-openfst-1.8.2.patch
 create mode 100644 srcpkgs/vosk-api/patches/series
 create mode 100644 srcpkgs/vosk-api/patches/vosk-lapack.patch
 create mode 100644 srcpkgs/vosk-api/template
 create mode 120000 srcpkgs/vosk-model-small-en-us

diff --git a/common/shlibs b/common/shlibs
index fd6908601c80..56b35351516f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4207,3 +4207,4 @@ libtracecmd.so.1 libtracecmd-3.1.2_1
 libkshark.so.2 libkshark-2.1.1_1
 libcpp-hocon.so.0.3.0 cpp-hocon-0.3.0_5
 libfst.so.25 openfst-1.8.2_1
+libvosk.so vosk-api-0.3.43_1
diff --git a/srcpkgs/vosk-api/patches/kaldi-lapack.patch b/srcpkgs/vosk-api/patches/kaldi-lapack.patch
new file mode 100644
index 000000000000..e40117beef5c
--- /dev/null
+++ b/srcpkgs/vosk-api/patches/kaldi-lapack.patch
@@ -0,0 +1,44 @@
+From 5f70761ecdf497cf55ca730187ab6ab38589ef0f Mon Sep 17 00:00:00 2001
+From: John Gebbie <me@johngebbie.com>
+Date: Sat, 3 Dec 2022 17:59:32 +0000
+Subject: [PATCH] Add OPENBLAS_NO_F2C math library option
+
+---
+ src/configure | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/src/configure b/src/configure
+index ed62daa5017..1d78489d55e 100755
+--- a/src/configure
++++ b/src/configure
+@@ -834,7 +834,7 @@ auto_lib=             # Deduced lib name, used when $MATHLIB is not set.
+ 
+ # Validate the (optionally) provided MATHLIB value.
+ case $MATHLIB in
+-  ''|ATLAS|CLAPACK|MKL|OPENBLAS|OPENBLAS_CLAPACK) : ;;
++  ''|ATLAS|CLAPACK|MKL|OPENBLAS|OPENBLAS_CLAPACK|OPENBLAS_NO_F2C) : ;;
+   *) failure "Unknown --mathlib='${MATHLIB}'. Supported libs: ATLAS CLAPACK MKL OPENBLAS" ;;
+ esac
+ 
+@@ -1301,7 +1301,7 @@ or try another math library, e.g. --mathlib=OPENBLAS (Kaldi may be slower)."
+     esac >> kaldi.mk
+ 
+     echo "Successfully configured for Linux with OpenBLAS from $OPENBLASROOT"
+-  elif [ "$MATHLIB" == "OPENBLAS_CLAPACK" ]; then
++  elif [ "$MATHLIB" == "OPENBLAS_CLAPACK" ] || [ "$MATHLIB" == "OPENBLAS_NO_F2C" ]; then
+     if [[ ! $OPENBLASROOT ]]; then
+       # Either the user specified --mathlib=OPENBLAS or we've autodetected the
+       # system where OpenBLAS is the preferred option (the parser for
+@@ -1345,7 +1345,11 @@ or try another math library, e.g. --mathlib=OPENBLAS (Kaldi may be slower)."
+       OPENBLASINCDIR="/usr/include"
+     fi
+     echo "Your math library seems to be OpenBLAS from $OPENBLASROOT.  Configuring appropriately."
+-    OPENBLASLIBS="-L$OPENBLASLIBDIR -l:libopenblas.a -l:libblas.a -l:liblapack.a -l:libf2c.a"
++    if [ "$MATHLIB" == "OPENBLAS_CLAPACK" ]; then
++        OPENBLASLIBS="-L$OPENBLASLIBDIR -l:libopenblas.a -l:libblas.a -l:liblapack.a -l:libf2c.a"
++    else
++        OPENBLASLIBS="-L$OPENBLASLIBDIR -l:libopenblas.a -l:libblas.a -l:liblapack.a"
++    fi
+     echo "OPENBLASINC = $OPENBLASINCDIR" >> kaldi.mk
+     echo "OPENBLASLIBS = $OPENBLASLIBS" >> kaldi.mk
+     echo >> kaldi.mk
diff --git a/srcpkgs/vosk-api/patches/kaldi-to-openblas-0.3.21.patch b/srcpkgs/vosk-api/patches/kaldi-to-openblas-0.3.21.patch
new file mode 100644
index 000000000000..4ae3aac80393
--- /dev/null
+++ b/srcpkgs/vosk-api/patches/kaldi-to-openblas-0.3.21.patch
@@ -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<char *>("U"), const_cast<char *>("N"), num_rows, Mdata, result);
++  stptri_(const_cast<char *>("U"), const_cast<char *>("N"), num_rows, Mdata, result, 1, 1);
+ }
+ inline void clapack_Xtptri(KaldiBlasInt *num_rows, double *Mdata, KaldiBlasInt *result) {
+-  dtptri_(const_cast<char *>("U"), const_cast<char *>("N"), num_rows, Mdata, result);
++  dtptri_(const_cast<char *>("U"), const_cast<char *>("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<char *>("U"), num_rows, Mdata, ipiv, work, result);
++  ssptri_(const_cast<char *>("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<char *>("U"), num_rows, Mdata, ipiv, work, result);
++  dsptri_(const_cast<char *>("U"), num_rows, Mdata, ipiv, work, result, 1);
+ }
+ //
+ void inline clapack_Xsptrf(KaldiBlasInt *num_rows, float *Mdata,
+                            KaldiBlasInt *ipiv, KaldiBlasInt *result) {
+-  ssptrf_(const_cast<char *>("U"), num_rows, Mdata, ipiv, result);
++  ssptrf_(const_cast<char *>("U"), num_rows, Mdata, ipiv, result, 1);
+ }
+ void inline clapack_Xsptrf(KaldiBlasInt *num_rows, double *Mdata,
+                            KaldiBlasInt *ipiv, KaldiBlasInt *result) {
+-  dsptrf_(const_cast<char *>("U"), num_rows, Mdata, ipiv, result);
++  dsptrf_(const_cast<char *>("U"), num_rows, Mdata, ipiv, result, 1);
+ }
+ #else
+ inline void clapack_Xgetrf(MatrixIndexT num_rows, MatrixIndexT num_cols,
diff --git a/srcpkgs/vosk-api/patches/kaldi-to-openfst-1.8.2.patch b/srcpkgs/vosk-api/patches/kaldi-to-openfst-1.8.2.patch
new file mode 100644
index 000000000000..6f2e1a343b2a
--- /dev/null
+++ b/srcpkgs/vosk-api/patches/kaldi-to-openfst-1.8.2.patch
@@ -0,0 +1,168 @@
+diff --git a/src/base/kaldi-types.h b/src/base/kaldi-types.h
+index 7ebf4f853..c376604a4 100644
+--- a/src/base/kaldi-types.h
++++ b/src/base/kaldi-types.h
+@@ -39,24 +39,21 @@ typedef float   BaseFloat;
+ // we find in the future lacks stdint.h
+ #include <stdint.h>
+ 
+-// for discussion on what to do if you need compile kaldi
+-// without OpenFST, see the bottom of this this file
+-#include <fst/types.h>
++#include <cstdlib>       // for ssize_t.
++#include <cstdint>       // for ?int*_t.
+ 
+-namespace kaldi {
+-  using ::int16;
+-  using ::int32;
+-  using ::int64;
+-  using ::uint16;
+-  using ::uint32;
+-  using ::uint64;
+-  typedef float   float32;
+-  typedef double double64;
+-}  // end namespace kaldi
++using int8 = int8_t;
++using int16 = int16_t;
++using int32 = int32_t;
++using int64 = int64_t;
++
++using uint8 = uint8_t;
++using uint16 = uint16_t;
++using uint32 = uint32_t;
++using uint64 = uint64_t;
+ 
+ // In a theoretical case you decide compile Kaldi without the OpenFST
+ // comment the previous namespace statement and uncomment the following
+-/*
+ namespace kaldi {
+   typedef int8_t   int8;
+   typedef int16_t  int16;
+@@ -70,6 +67,5 @@ namespace kaldi {
+   typedef float    float32;
+   typedef double   double64;
+ }  // end namespace kaldi
+-*/
+ 
+ #endif  // KALDI_BASE_KALDI_TYPES_H_
+diff --git a/src/configure b/src/configure
+index c74d67af8..84286da01 100755
+--- a/src/configure
++++ b/src/configure
+@@ -929,7 +929,7 @@ fi
+ OPENFST_VER=${OPENFST_VER:-$(grep 'PACKAGE_VERSION' $FSTROOT/Makefile | sed -e 's:.*= ::')}
+ OPENFST_VER_NUM=$(echo $OPENFST_VER | sed 's/\./ /g' | xargs printf "%d%02d%02d")
+ if [ $OPENFST_VER_NUM -lt 10600 ]; then
+-  failure "OpenFst-$OPENFST_VER is not supported. You need OpenFst >= 1.6.0.)"
++  :
+ fi
+ echo "OPENFSTINC = $FSTROOT/include" >> kaldi.mk
+ if $static_fst ; then
+diff --git a/src/fstext/kaldi-fst-io-inl.h b/src/fstext/kaldi-fst-io-inl.h
+index f7bb3a7c2..01047919c 100644
+--- a/src/fstext/kaldi-fst-io-inl.h
++++ b/src/fstext/kaldi-fst-io-inl.h
+@@ -99,7 +99,7 @@ void ReadFstKaldi(std::istream &is, bool binary,
+     fst->DeleteStates();
+     string line;
+     size_t nline = 0;
+-    string separator = FLAGS_fst_field_separator + "\r\n";
++    string separator = FST_FLAGS_fst_field_separator + "\r\n";
+     while (std::getline(is, line)) {
+       nline++;
+       vector<string> col;
+diff --git a/src/fstext/lattice-weight.h b/src/fstext/lattice-weight.h
+index 7637c4d1c..2d82c5647 100644
+--- a/src/fstext/lattice-weight.h
++++ b/src/fstext/lattice-weight.h
+@@ -396,8 +396,8 @@ inline bool ApproxEqual(const LatticeWeightTpl<FloatType> &w1,
+ template <class FloatType>
+ inline std::ostream &operator <<(std::ostream &strm, const LatticeWeightTpl<FloatType> &w) {
+   LatticeWeightTpl<FloatType>::WriteFloatType(strm, w.Value1());
+-  CHECK(FLAGS_fst_weight_separator.size() == 1);
+-  strm << FLAGS_fst_weight_separator[0]; // comma by default;
++  CHECK(FST_FLAGS_fst_weight_separator.size() == 1);
++  strm << FST_FLAGS_fst_weight_separator[0]; // comma by default;
+   // may or may not be settable from Kaldi programs.
+   LatticeWeightTpl<FloatType>::WriteFloatType(strm, w.Value2());
+   return strm;
+@@ -405,9 +405,9 @@ inline std::ostream &operator <<(std::ostream &strm, const LatticeWeightTpl<Floa
+ 
+ template <class FloatType>
+ inline std::istream &operator >>(std::istream &strm, LatticeWeightTpl<FloatType> &w1) {
+-  CHECK(FLAGS_fst_weight_separator.size() == 1);
++  CHECK(FST_FLAGS_fst_weight_separator.size() == 1);
+   // separator defaults to ','
+-  return w1.ReadNoParen(strm, FLAGS_fst_weight_separator[0]);
++  return w1.ReadNoParen(strm, FST_FLAGS_fst_weight_separator[0]);
+ }
+ 
+ 
+@@ -728,8 +728,8 @@ inline CompactLatticeWeightTpl<WeightType, IntType> Divide(const CompactLatticeW
+ template <class WeightType, class IntType>
+ inline std::ostream &operator <<(std::ostream &strm, const CompactLatticeWeightTpl<WeightType, IntType> &w) {
+   strm << w.Weight();
+-  CHECK(FLAGS_fst_weight_separator.size() == 1);
+-  strm << FLAGS_fst_weight_separator[0]; // comma by default.
++  CHECK(FST_FLAGS_fst_weight_separator.size() == 1);
++  strm << FST_FLAGS_fst_weight_separator[0]; // comma by default.
+   for(size_t i = 0; i < w.String().size(); i++) {
+     strm << w.String()[i];
+     if (i+1 < w.String().size())
+@@ -745,8 +745,8 @@ inline std::istream &operator >>(std::istream &strm, CompactLatticeWeightTpl<Wei
+   if (strm.fail()) {
+     return strm;
+   }
+-  CHECK(FLAGS_fst_weight_separator.size() == 1);
+-  size_t pos = s.find_last_of(FLAGS_fst_weight_separator); // normally ","
++  CHECK(FST_FLAGS_fst_weight_separator.size() == 1);
++  size_t pos = s.find_last_of(FST_FLAGS_fst_weight_separator); // normally ","
+   if (pos == std::string::npos) {
+     strm.clear(std::ios::badbit);
+     return strm;
+diff --git a/src/fstext/trivial-factor-weight.h b/src/fstext/trivial-factor-weight.h
+index d1c679f7f..90bab80db 100644
+--- a/src/fstext/trivial-factor-weight.h
++++ b/src/fstext/trivial-factor-weight.h
+@@ -390,7 +390,7 @@ class ArcIterator< TrivialFactorWeightFst<A, F> >
+ template <class A, class F>
+ inline void TrivialFactorWeightFst<A, F>::InitStateIterator(
+     StateIteratorData<A> *data) const {
+-  data->base = fst::make_unique<StateIterator<TrivialFactorWeightFst<A, F> > >(*this);
++  data->base = std::make_unique<StateIterator<TrivialFactorWeightFst<A, F> > >(*this);
+ }
+ 
+ 
+diff --git a/src/lat/kaldi-lattice.cc b/src/lat/kaldi-lattice.cc
+index 648e67115..70fde5acf 100644
+--- a/src/lat/kaldi-lattice.cc
++++ b/src/lat/kaldi-lattice.cc
+@@ -114,7 +114,7 @@ class LatticeReader {
+     CompactLattice *cfst = new CompactLattice();
+     string line;
+     size_t nline = 0;
+-    string separator = FLAGS_fst_field_separator + "\r\n";
++    string separator = FST_FLAGS_fst_field_separator + "\r\n";
+     while (std::getline(is, line)) {
+       nline++;
+       vector<string> col;
+diff --git a/src/lat/lattice-functions-transition-model.cc b/src/lat/lattice-functions-transition-model.cc
+index 6172610dc..a8cd7b7e2 100644
+--- a/src/lat/lattice-functions-transition-model.cc
++++ b/src/lat/lattice-functions-transition-model.cc
+@@ -248,13 +248,13 @@ bool TestWordAlignedLattice(const WordAlignLatticeLexiconInfo &lexicon_info,
+   int32 num_paths = 5, seed = Rand(), max_path_length = -1;
+   BaseFloat delta = 0.2; // some lattices have large costs -> use large delta.
+ 
+-  FLAGS_v = GetVerboseLevel(); // set the OpenFst verbose level to the Kaldi
++  FST_FLAGS_v = GetVerboseLevel(); // set the OpenFst verbose level to the Kaldi
+                                // verbose level.
+   if (!RandEquivalent(clat, aligned_clat, num_paths, delta, seed, max_path_length)) {
+     KALDI_WARN << "Equivalence test failed during lattice alignment.";
+     return false;
+   }
+-  FLAGS_v = 0;
++  FST_FLAGS_v = 0;
+ 
+   return (num_err == 0);
+ }
diff --git a/srcpkgs/vosk-api/patches/series b/srcpkgs/vosk-api/patches/series
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/srcpkgs/vosk-api/patches/vosk-lapack.patch b/srcpkgs/vosk-api/patches/vosk-lapack.patch
new file mode 100644
index 000000000000..8751f3c77d9c
--- /dev/null
+++ b/srcpkgs/vosk-api/patches/vosk-lapack.patch
@@ -0,0 +1,40 @@
+From 6c28207334bb1281d98a94f799757fdfa8f6b336 Mon Sep 17 00:00:00 2001
+From: John Gebbie <me@johngebbie.com>
+Date: Sat, 3 Dec 2022 17:53:21 +0000
+Subject: [PATCH] Add OPENBLAS_NO_F2C math library option
+
+---
+ src/Makefile | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/src/Makefile b/src/Makefile
+index cd697b15..97654883 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -7,6 +7,7 @@ CUDA_ROOT?=/usr/local/cuda
+ USE_SHARED?=0
+ # Math libraries
+ HAVE_OPENBLAS_CLAPACK?=1
++HAVE_OPENBLAS_NO_F2C?=0
+ HAVE_MKL?=0
+ HAVE_ACCELERATE=0
+ HAVE_CUDA?=0
+@@ -80,6 +81,18 @@ ifeq ($(HAVE_OPENBLAS_CLAPACK), 1)
+     endif
+ endif
+ 
++ifeq ($(HAVE_OPENBLAS_NO_F2C), 1)
++    CFLAGS += -I$(OPENBLAS_ROOT)/include
++    ifeq ($(USE_SHARED), 0)
++        LIBS += \
++            $(OPENBLAS_ROOT)/lib/libopenblas.a \
++            $(OPENBLAS_ROOT)/lib/liblapack.a \
++            $(OPENBLAS_ROOT)/lib/libblas.a
++    else
++        LDFLAGS += -lopenblas -llapack -lblas
++    endif
++endif
++
+ ifeq ($(HAVE_MKL), 1)
+     CFLAGS += -DHAVE_MKL=1 -I$(MKL_ROOT)/include
+     LDFLAGS += -L$(MKL_ROOT)/lib/intel64 -Wl,-rpath=$(MKL_ROOT)/lib/intel64 -lmkl_rt -lmkl_intel_lp64 -lmkl_core -lmkl_sequential
diff --git a/srcpkgs/vosk-api/template b/srcpkgs/vosk-api/template
new file mode 100644
index 000000000000..b3100d2f151a
--- /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
+create_wrksrc=yes
+build_wrksrc="vosk-api-${version}/src"
+_kaldi_commit=ecb4b47159501ef0d67888633e65b8fc0c1f79d1
+build_style=gnu-makefile
+make_use_env=yes
+make_build_args="KALDI_ROOT=../../kaldi-${_kaldi_commit} 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"
+
+do_patch() {
+	# https://github.com/alphacep/kaldi/pull/5
+	patch -Np1 -d "${wrksrc}/kaldi-${_kaldi_commit}" < "${PATCHESDIR}/kaldi-lapack.patch"
+	patch -Np1 -d "${wrksrc}/kaldi-${_kaldi_commit}" < "${PATCHESDIR}/kaldi-to-openblas-0.3.21.patch"
+	patch -Np1 -d "${wrksrc}/kaldi-${_kaldi_commit}" < "${PATCHESDIR}/kaldi-to-openfst-1.8.2.patch"
+	# https://github.com/alphacep/vosk-api/pull/1215
+	patch -Np1 -d "${wrksrc}/vosk-api-${version}" < "${PATCHESDIR}/vosk-lapack.patch"
+}
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	makedepends+=" libexecinfo-devel"
+fi
+
+post_extract() {
+	cd "${wrksrc}/kaldi-${_kaldi_commit}/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-${_kaldi_commit}/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
+	}
+}
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

  parent reply	other threads:[~2022-12-04  8:19 UTC|newest]

Thread overview: 134+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 21:38 [PR PATCH] New package: libvosk-0.3.43 JohnGebbie
2022-09-02  7:33 ` JohnGebbie
2022-09-02  9:01 ` JohnGebbie
2022-09-02 18:59 ` JohnGebbie
2022-09-03 12:04 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-03 12:11 ` New package: vosk-api-0.3.43 JohnGebbie
2022-09-03 14:11 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-03 14:12 ` JohnGebbie
2022-09-03 14:13 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-03 14:14 ` JohnGebbie
2022-09-03 14:14 ` JohnGebbie
2022-09-03 20:52 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-04  8:26 ` JohnGebbie
2022-09-17 13:05 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-17 13:09 ` JohnGebbie
2022-09-18 11:00 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-21 15:53 ` JohnGebbie
2022-09-22  8:53 ` JohnGebbie
2022-09-22  9:26 ` [PR REVIEW] " paper42
2022-09-22  9:26 ` paper42
2022-09-22 14:39 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-22 14:43 ` JohnGebbie
2022-09-22 15:19 ` [PR REVIEW] " JohnGebbie
2022-09-22 18:16 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-22 19:32 ` JohnGebbie
2022-09-22 19:38 ` JohnGebbie
2022-09-22 20:31 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-22 20:33 ` JohnGebbie
2022-09-22 20:50 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-22 20:50 ` JohnGebbie
2022-09-23  8:55 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-23  9:14 ` JohnGebbie
2022-09-23 11:30 ` JohnGebbie
2022-09-23 17:21 ` JohnGebbie
2022-09-23 18:23 ` JohnGebbie
2022-09-26 22:16 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-26 22:18 ` JohnGebbie
2022-09-28 15:44 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-28 15:44 ` JohnGebbie
2022-09-28 15:53 ` JohnGebbie
2022-09-29 20:24 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-29 20:30 ` JohnGebbie
2022-09-30  9:15 ` JohnGebbie
2022-09-30 14:27 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-30 14:27 ` JohnGebbie
2022-09-30 14:30 ` JohnGebbie
2022-09-30 19:14 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-30 19:21 ` JohnGebbie
2022-09-30 19:47 ` JohnGebbie
2022-09-30 19:54 ` [PR PATCH] [Updated] " JohnGebbie
2022-09-30 21:15 ` JohnGebbie
2022-10-01 10:26 ` JohnGebbie
2022-10-02 16:27 ` JohnGebbie
2022-10-03 11:19 ` [PR PATCH] [Updated] " JohnGebbie
2022-10-03 11:21 ` JohnGebbie
2022-10-03 12:39 ` JohnGebbie
2022-10-04 19:17 ` JohnGebbie
2022-10-08 12:13 ` [PR PATCH] [Updated] " JohnGebbie
2022-10-08 12:15 ` JohnGebbie
2022-10-08 12:21 ` JohnGebbie
2022-10-08 14:32 ` [PR PATCH] [Updated] " JohnGebbie
2022-10-08 15:52 ` JohnGebbie
2022-10-08 16:24 ` [PR PATCH] [Updated] " JohnGebbie
2022-10-08 16:25 ` JohnGebbie
2022-10-08 16:33 ` JohnGebbie
2022-10-09 10:37 ` [PR PATCH] [Updated] " JohnGebbie
2022-10-09 10:38 ` JohnGebbie
2022-10-09 10:46 ` JohnGebbie
2022-10-26 15:57 ` JohnGebbie
2022-10-26 15:57 ` JohnGebbie
2022-10-26 15:57 ` JohnGebbie
2022-10-26 15:58 ` JohnGebbie
2022-10-26 15:58 ` JohnGebbie
2022-10-26 15:58 ` JohnGebbie
2022-10-26 15:59 ` JohnGebbie
2022-10-26 15:59 ` JohnGebbie
2022-10-26 15:59 ` JohnGebbie
2022-10-26 16:00 ` JohnGebbie
2022-10-26 16:00 ` JohnGebbie
2022-10-26 16:00 ` JohnGebbie
2022-10-26 16:01 ` JohnGebbie
2022-10-27  9:59 ` [PR PATCH] [Updated] " JohnGebbie
2022-10-27 10:18 ` JohnGebbie
2022-10-27 21:37 ` JohnGebbie
2022-10-28  8:33 ` JohnGebbie
2022-10-28  9:43 ` JohnGebbie
2022-10-28 17:01 ` [PR PATCH] [Updated] " JohnGebbie
2022-10-28 18:49 ` JohnGebbie
2022-10-28 20:15 ` JohnGebbie
2022-10-28 20:45 ` JohnGebbie
2022-10-28 21:42 ` JohnGebbie
2022-10-29  8:41 ` JohnGebbie
2022-10-29 11:45 ` JohnGebbie
2022-10-29 12:07 ` JohnGebbie
2022-10-29 14:09 ` JohnGebbie
2022-11-09 17:33 ` JohnGebbie
2022-11-14 22:54 ` [PR REVIEW] " paper42
2022-11-14 22:54 ` paper42
2022-11-14 22:54 ` paper42
2022-11-14 22:54 ` paper42
2022-11-14 22:54 ` paper42
2022-11-14 22:54 ` paper42
2022-11-14 22:54 ` paper42
2022-11-15 11:04 ` JohnGebbie
2022-11-15 13:38 ` [PR PATCH] [Updated] " JohnGebbie
2022-11-15 14:23 ` [PR REVIEW] " JohnGebbie
2022-11-15 14:24 ` JohnGebbie
2022-11-15 14:44 ` [PR PATCH] [Updated] " JohnGebbie
2022-11-15 14:54 ` [PR REVIEW] " JohnGebbie
2022-12-03 18:32 ` [PR PATCH] [Updated] " JohnGebbie
2022-12-03 18:37 ` JohnGebbie
2022-12-03 18:38 ` [PR REVIEW] " JohnGebbie
2022-12-03 18:43 ` JohnGebbie
2022-12-03 18:44 ` JohnGebbie
2022-12-03 18:47 ` JohnGebbie
2022-12-03 18:48 ` JohnGebbie
2022-12-03 20:52 ` JohnGebbie
2022-12-03 21:22 ` [PR PATCH] [Updated] " JohnGebbie
2022-12-03 21:26 ` JohnGebbie
2022-12-04  8:19 ` JohnGebbie [this message]
2022-12-04  8:21 ` JohnGebbie
2022-12-04 10:25 ` JohnGebbie
2022-12-04 12:46 ` [PR REVIEW] " paper42
2022-12-04 12:46 ` paper42
2022-12-04 12:46 ` paper42
2022-12-04 12:46 ` paper42
2022-12-04 12:46 ` paper42
2022-12-04 13:52 ` [PR PATCH] [Updated] " JohnGebbie
2022-12-04 13:55 ` [PR REVIEW] " JohnGebbie
2022-12-04 14:04 ` paper42
2022-12-04 14:33 ` [PR PATCH] [Updated] " JohnGebbie
2022-12-04 16:09 ` JohnGebbie
2022-12-04 16:10 ` [PR PATCH] [Merged]: " paper42
2022-12-04 16:11 ` JohnGebbie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221204081944.wuJAHIVLmxGO-PKUKtODBJFaGlzBneNS1bXlS6W12fM@z \
    --to=johngebbie@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).