diff options
Diffstat (limited to 'meta-offline-voice-agent/recipes-vosk')
12 files changed, 519 insertions, 0 deletions
diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Build-fix-for-include-in-makefile.patch b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Build-fix-for-include-in-makefile.patch new file mode 100644 index 00000000..8c67aba7 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Build-fix-for-include-in-makefile.patch @@ -0,0 +1,25 @@ +From 29caad5ea644875d7d896836d5c8c67a711b4352 Mon Sep 17 00:00:00 2001 +From: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +Date: Wed, 13 Jul 2022 15:52:29 +0000 +Subject: [PATCH] Build fix for include in makefile + +There is a conflict when using -isystem and bitbake's own flags. + +Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +--- + src/makefiles/linux_openblas.mk | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/makefiles/linux_openblas.mk b/src/makefiles/linux_openblas.mk +index 1ac67c355..bb15f84a5 100644 +--- a/src/makefiles/linux_openblas.mk ++++ b/src/makefiles/linux_openblas.mk +@@ -19,7 +19,7 @@ ifndef OPENBLASLIBS + $(error OPENBLASLIBS not defined.) + endif + +-CXXFLAGS = -std=c++17 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \ ++CXXFLAGS = -std=c++17 -I.. -I $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \ + -Wall -Wno-sign-compare -Wno-unused-local-typedefs \ + -Wno-deprecated-declarations -Winit-self \ + -DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \ diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Enforce-cross-compilation-under-bitbake.patch b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Enforce-cross-compilation-under-bitbake.patch new file mode 100644 index 00000000..d1fb4836 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Enforce-cross-compilation-under-bitbake.patch @@ -0,0 +1,23 @@ +From 47f7b9dec92f52e3bd7d497326a2e5d28e3cf10c Mon Sep 17 00:00:00 2001 +From: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +Date: Mon, 11 Jul 2022 16:50:23 +0200 +Subject: [PATCH] Enforce cross-compilation under bitbake + +Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +--- + src/configure | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/configure b/src/configure +index c74d67af8..2aaf541c3 100755 +--- a/src/configure ++++ b/src/configure +@@ -232,7 +232,7 @@ You need $supported_compiler." + + function check_for_slow_expf { + # We cannot run this test if we are cross compiling. +- if [[ "$TARGET_ARCH" == "`uname -m`" ]] ; then ++ if false ; then + ( cd probe + rm -f exp-test + make -f Makefile.slow_expf 1>/dev/null diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Fixes-for-shared-library-compilation.patch b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Fixes-for-shared-library-compilation.patch new file mode 100644 index 00000000..fb93a356 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/0001-Fixes-for-shared-library-compilation.patch @@ -0,0 +1,95 @@ +From 4fc5d1df4dca9b7faaf630d43b32a85d80d16eb3 Mon Sep 17 00:00:00 2001 +From: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +Date: Thu, 14 Jul 2022 11:00:07 +0000 +Subject: [PATCH] Fixes for shared library compilation + +Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +--- + src/configure | 2 +- + src/fstbin/Makefile | 3 ++- + src/latbin/Makefile | 3 ++- + src/makefiles/linux_openblas.mk | 2 +- + src/matrix/Makefile | 2 +- + src/rnnlmbin/Makefile | 2 +- + 6 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/src/configure b/configure +index c74d67af8..2aaf541c3 100755 +--- a/configure ++++ b/configure +@@ -232,7 +232,7 @@ You need $supported_compiler." + + function check_for_slow_expf { + # We cannot run this test if we are cross compiling. +- if [[ "$TARGET_ARCH" == "`uname -m`" ]] ; then ++ if false ; then + ( cd probe + rm -f exp-test + make -f Makefile.slow_expf 1>/dev/null +diff --git a/fstbin/Makefile b/fstbin/Makefile +index a22c014a7..5a29030c3 100644 +--- a/fstbin/Makefile ++++ b/fstbin/Makefile +@@ -26,6 +26,7 @@ TESTFILES = + LIBFILE = + + ADDLIBS = ../decoder/kaldi-decoder.a ../fstext/kaldi-fstext.a \ +- ../util/kaldi-util.a ../matrix/kaldi-matrix.a ../base/kaldi-base.a ++ ../util/kaldi-util.a ../matrix/kaldi-matrix.a ../base/kaldi-base.a \ ++ ../hmm/kaldi-hmm.a ../lat/kaldi-lat.a ../tree/kaldi-tree.a + + include ../makefiles/default_rules.mk +diff --git a/latbin/Makefile b/latbin/Makefile +index d5cc4d035..902bf1058 100644 +--- a/latbin/Makefile ++++ b/latbin/Makefile +@@ -36,6 +36,7 @@ TESTFILES = + ADDLIBS = ../rnnlm/kaldi-rnnlm.a ../nnet3/kaldi-nnet3.a \ + ../cudamatrix/kaldi-cudamatrix.a ../lat/kaldi-lat.a ../lm/kaldi-lm.a \ + ../fstext/kaldi-fstext.a ../hmm/kaldi-hmm.a ../tree/kaldi-tree.a \ +- ../util/kaldi-util.a ../matrix/kaldi-matrix.a ../base/kaldi-base.a ++ ../util/kaldi-util.a ../matrix/kaldi-matrix.a ../base/kaldi-base.a \ ++ ../chain/kaldi-chain.a ../decoder/kaldi-decoder.a + + include ../makefiles/default_rules.mk +diff --git a/makefiles/linux_openblas.mk b/makefiles/linux_openblas.mk +index 1ac67c355..bb15f84a5 100644 +--- a/makefiles/linux_openblas.mk ++++ b/makefiles/linux_openblas.mk +@@ -19,7 +19,7 @@ ifndef OPENBLASLIBS + $(error OPENBLASLIBS not defined.) + endif + +-CXXFLAGS = -std=c++17 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \ ++CXXFLAGS = -std=c++17 -I.. -I $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \ + -Wall -Wno-sign-compare -Wno-unused-local-typedefs \ + -Wno-deprecated-declarations -Winit-self \ + -DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \ +diff --git a/matrix/Makefile b/matrix/Makefile +index 398179a35..bec14e089 100644 +--- a/matrix/Makefile ++++ b/matrix/Makefile +@@ -10,7 +10,7 @@ include ../kaldi.mk + + # you can uncomment matrix-lib-speed-test if you want to do the speed tests. + +-TESTFILES = matrix-lib-test sparse-matrix-test numpy-array-test #matrix-lib-speed-test ++#TESTFILES = matrix-lib-test sparse-matrix-test numpy-array-test #matrix-lib-speed-test + + OBJFILES = kaldi-matrix.o kaldi-vector.o packed-matrix.o sp-matrix.o tp-matrix.o \ + matrix-functions.o qr.o srfft.o compressed-matrix.o \ +diff --git a/rnnlmbin/Makefile b/rnnlmbin/Makefile +index 23a8eba61..d801b90d8 100644 +--- a/rnnlmbin/Makefile ++++ b/rnnlmbin/Makefile +@@ -21,6 +21,6 @@ ADDLIBS = ../rnnlm/kaldi-rnnlm.a ../nnet3/kaldi-nnet3.a \ + ../lat/kaldi-lat.a ../lm/kaldi-lm.a ../fstext/kaldi-fstext.a \ + ../hmm/kaldi-hmm.a ../transform/kaldi-transform.a ../gmm/kaldi-gmm.a \ + ../tree/kaldi-tree.a ../util/kaldi-util.a ../matrix/kaldi-matrix.a \ +- ../base/kaldi-base.a ++ ../base/kaldi-base.a ../chain/kaldi-chain.a + + include ../makefiles/default_rules.mk +-- +2.33.0 + diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/OLD/0001-Build-fix-for-include-in-makefile.patch b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/OLD/0001-Build-fix-for-include-in-makefile.patch new file mode 100644 index 00000000..8c67aba7 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/OLD/0001-Build-fix-for-include-in-makefile.patch @@ -0,0 +1,25 @@ +From 29caad5ea644875d7d896836d5c8c67a711b4352 Mon Sep 17 00:00:00 2001 +From: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +Date: Wed, 13 Jul 2022 15:52:29 +0000 +Subject: [PATCH] Build fix for include in makefile + +There is a conflict when using -isystem and bitbake's own flags. + +Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +--- + src/makefiles/linux_openblas.mk | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/makefiles/linux_openblas.mk b/src/makefiles/linux_openblas.mk +index 1ac67c355..bb15f84a5 100644 +--- a/src/makefiles/linux_openblas.mk ++++ b/src/makefiles/linux_openblas.mk +@@ -19,7 +19,7 @@ ifndef OPENBLASLIBS + $(error OPENBLASLIBS not defined.) + endif + +-CXXFLAGS = -std=c++17 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \ ++CXXFLAGS = -std=c++17 -I.. -I $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \ + -Wall -Wno-sign-compare -Wno-unused-local-typedefs \ + -Wno-deprecated-declarations -Winit-self \ + -DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \ diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/OLD/0001-Enforce-cross-compilation-under-bitbake.patch b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/OLD/0001-Enforce-cross-compilation-under-bitbake.patch new file mode 100644 index 00000000..d1fb4836 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi/OLD/0001-Enforce-cross-compilation-under-bitbake.patch @@ -0,0 +1,23 @@ +From 47f7b9dec92f52e3bd7d497326a2e5d28e3cf10c Mon Sep 17 00:00:00 2001 +From: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +Date: Mon, 11 Jul 2022 16:50:23 +0200 +Subject: [PATCH] Enforce cross-compilation under bitbake + +Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +--- + src/configure | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/configure b/src/configure +index c74d67af8..2aaf541c3 100755 +--- a/src/configure ++++ b/src/configure +@@ -232,7 +232,7 @@ You need $supported_compiler." + + function check_for_slow_expf { + # We cannot run this test if we are cross compiling. +- if [[ "$TARGET_ARCH" == "`uname -m`" ]] ; then ++ if false ; then + ( cd probe + rm -f exp-test + make -f Makefile.slow_expf 1>/dev/null diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi_git.bb b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi_git.bb new file mode 100644 index 00000000..b3e021f3 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-kaldi/vosk-kaldi_git.bb @@ -0,0 +1,63 @@ +SUMMARY = "Kaldi Speech Recognition Toolkit" +HOMEPAGE = "http://kaldi-asr.org/" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://../COPYING;md5=a10e448a64dbd3723ff3fb2f397fba2e \ + file://doc/legal.dox;md5=3cba845003f27e67da70faa5da924c1e" + +SRC_URI = "git://github.com/alphacep/kaldi.git;protocol=https;branch=vosk \ + file://0001-Fixes-for-shared-library-compilation.patch \ + " + +PV = "1.0+git${SRCPV}" +SRCREV = "76cd51d44c0a61e3905c35cadb2ec5f54f3e42d1" + +S = "${WORKDIR}/git/src" + +DEPENDS += "openblas vosk-openfst" +inherit python3native + +ALLOW_EMPTY_${PN} = "1" + +MYCONF = "--mathlib=OPENBLAS --static --shared --use-cuda=no --fst-root=${STAGING_INCDIR}/../ --fst-version=1.8.0 --openblas-root=${STAGING_INCDIR}/../ " + +do_configure() { + + ./configure ${MYCONF} + +} + +do_compile() { + + make ${PARALLEL_MAKE} + +} + +do_install() { + + install -d ${D}${libdir} + + for i in lib/*.so ; do + install -m 0644 ${i} ${D}${libdir}/ + done + + for i in */*.a ; do + install -m 0644 ${i} ${D}${libdir}/ + done + + for j in base chain decoder feat fstext gmm gst-plugin hmm itf ivector kws lat lm matrix nnet nnet2 nnet3 online online2 rnnlm sgmm2 tfrnnlm transform tree util cudadecoder cudadecoderbin cudafeat cudamatrix ; do + install -d ${D}${includedir}/kaldi/$j + for i in $j/*.h ; do + install -m 0644 $i ${D}${includedir}/kaldi/$j/ + done + done + + # make sure we have the package vosk-kaldi + + install -d ${D}/usr/share/kaldi + echo "This is vosk-kaldi" > ${D}/usr/share/kaldi/README + +} + +FILES:${PN} += " /usr/share/kaldi /usr/share/kaldi/README" +ERROR_QA:remove = "rpaths" +ERROR_QA:remove = "dev-elf" diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-model-small-en-us/vosk-model-small-en-us_0.15.bb b/meta-offline-voice-agent/recipes-vosk/vosk-model-small-en-us/vosk-model-small-en-us_0.15.bb new file mode 100644 index 00000000..3a408a65 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-model-small-en-us/vosk-model-small-en-us_0.15.bb @@ -0,0 +1,23 @@ +SUMMARY = "Lightweight wideband model 'en-us'" +HOMEPAGE = "https://alphacephei.com/vosk/" +LICENSE = "Apache-2.0" +# LIC_URL = "${COMMON_LICENSE_DIR}/Apache-2.0" +LIC_FILES_CHKSUM = "file://${WORKDIR}/models.md;beginline=32;endline=32;md5=bb5cd71a409da2b13fa3bcb67a3573d1" + +SRC_URI = " \ + https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip;name=model \ + https://raw.githubusercontent.com/alphacep/vosk-space/master/models.md;name=license \ + " +# License listed on https://alphacephei.com/vosk/models + +SRC_URI[model.sha256sum] = "30f26242c4eb449f948e42cb302dd7a686cb29a3423a8367f99ff41780942498" +SRC_URI[license.sha256sum] = "3fbe0ee1fa914cb4b1cea2f2d7201a155884727cd0afbb51a267b66a73cb3444" + +do_install() { + install -d ${D}/usr/share/vosk + cp -R ${WORKDIR}/vosk-model-small-en-us-0.15/ ${D}/usr/share/vosk/ +} + +FILES:${PN} += " /usr/share/vosk /usr/share/vosk/vosk-model-small-en-us-0.15 " + +RPROVIDES:${PN} += "virtual/vosk-model" diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-openfst/files/0001-build-fixes-for-bitbake.patch b/meta-offline-voice-agent/recipes-vosk/vosk-openfst/files/0001-build-fixes-for-bitbake.patch new file mode 100644 index 00000000..fd3234c8 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-openfst/files/0001-build-fixes-for-bitbake.patch @@ -0,0 +1,64 @@ +From 8f5bc403c58af348d9671ca390c34cabde89a529 Mon Sep 17 00:00:00 2001 +From: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +Date: Sat, 9 Jul 2022 16:49:10 +0200 +Subject: [PATCH] build fixes for bitbake + +Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +--- + configure.ac | 36 +----------------------------------- + 1 file changed, 1 insertion(+), 35 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 9ab8824..316f719 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5,7 +5,7 @@ AM_PROG_AR + AC_PROG_CXX + # This library does not throw exceptions, so we do not generate exception + # handling code. However, users are free to re-enable exception handling. +-CXX="$CXX -std=c++17 -fno-exceptions -Wno-deprecated-declarations" ++#CXX="$CXX -std=c++17 -fno-exceptions -Wno-deprecated-declarations" + + AC_DISABLE_STATIC + AC_PROG_LIBTOOL +@@ -149,40 +149,6 @@ AC_ARG_WITH([libfstdir], + + AC_SUBST([libfstdir], $with_libfstdir) + +-# Flags may be changed after configuring, so this is checked again by +-# weight_test.cc. The check here is to save time in the common case, +-# or when someone does not run `make check`. +-AC_RUN_IFELSE([AC_LANG_PROGRAM([ +- #include <cstdio> +- +- template <typename T> +- bool FloatEqIsReflexive(T m) { +- volatile T x = 1.111; +- x *= m; +- +- T y = 1.111; +- y *= m; +- +- return x == y; +- } +- ], [ +- volatile double test_value = 1.1; +- if (!FloatEqIsReflexive(static_cast<float>(test_value))) { +- printf("float FAIL\n"); +- return 1; +- } +- if (!FloatEqIsReflexive(test_value)) { +- printf("double FAIL\n"); +- return 1; +- } +- ])], +- [echo "Float equality is good"], +- [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/meta-offline-voice-agent/recipes-vosk/vosk-openfst/vosk-openfst_1.8.0.bb b/meta-offline-voice-agent/recipes-vosk/vosk-openfst/vosk-openfst_1.8.0.bb new file mode 100644 index 00000000..c7e07bfe --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-openfst/vosk-openfst_1.8.0.bb @@ -0,0 +1,23 @@ +DESCRIPTION = "OpenFst is a library for constructing, combining, optimizing, and searching weighted finite-state transducers (FSTs)." +SUMMARY = "Openfst mirror with some fixes" +HOMEPAGE = "https://github.com/alphacep/openfst" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://COPYING;md5=973381090441f4eb420224655e05e064" + +SRC_URI = "git://github.com/alphacep/openfst.git;protocol=https;branch=master \ + file://0001-build-fixes-for-bitbake.patch \ + " + +SRCREV = "7dfd808194105162f20084bb4d8e4ee4b65266d5" +S = "${WORKDIR}/git" + +inherit autotools python3native + +# Specify any options you want to pass to the configure script using EXTRA_OECONF: +EXTRA_OECONF = "--enable-static --enable-shared --enable-far --enable-ngram-fsts --enable-lookahead-fsts --with-pic --disable-bin" + +FILES:${PN} += " /usr/lib/fst /usr/lib/fst/arc_lookahead-fst.so \ + /usr/lib/fst/ilabel_lookahead-fst.so \ + /usr/lib/fst/ngram-fst.so \ + /usr/lib/fst/olabel_lookahead-fst.so \ +" diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-server/vosk-server_git.bb b/meta-offline-voice-agent/recipes-vosk/vosk-server/vosk-server_git.bb new file mode 100644 index 00000000..337cee46 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-server/vosk-server_git.bb @@ -0,0 +1,32 @@ +DESCRIPTION = "WebSocket, gRPC and WebRTC speech recognition server based on Vosk and Kaldi libraries" +SUMMARY = "This is a server for highly accurate offline speech recognition using Kaldi and Vosk-API." +HOMEPAGE = "https://github.com/alphacep/vosk-server" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://COPYING;md5=d09bbd7a3746b6052fbd78b26a87396b" + +SRC_URI = "git://github.com/alphacep/vosk-server;protocol=https;branch=master" + +PV = "1.0+git${SRCPV}" +SRCREV = "70f3d5321a40f2f5dffe9c833bc1fac4b3b451e7" + +S = "${WORKDIR}/git" + +DEPENDS = "python3-vosk-api openblas vosk boost" + +do_configure () { + : +} + +do_compile () { + # websocket-cpp + cd websocket-cpp + ${CXX} -I${STAGING_INCDIR}/vosk -lvosk ${LDFLAGS} -o vosk-websocket-cpp asr_server.cpp +} + +do_install () { + # websocket-cpp + install -d ${D}${bindir} + cp websocket-cpp/vosk-websocket-cpp ${D}${bindir} +} + +RDEPENDS:${PN} += "virtual/vosk-model"
\ No newline at end of file diff --git a/meta-offline-voice-agent/recipes-vosk/vosk/vosk/0001-Build-fixes-for-shared-library-under-bitbake.patch b/meta-offline-voice-agent/recipes-vosk/vosk/vosk/0001-Build-fixes-for-shared-library-under-bitbake.patch new file mode 100644 index 00000000..65bb866b --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk/vosk/0001-Build-fixes-for-shared-library-under-bitbake.patch @@ -0,0 +1,74 @@ +From be3688fc475ece12d0fb8b7bcb993b053e91d3ec Mon Sep 17 00:00:00 2001 +From: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +Date: Thu, 14 Jul 2022 18:31:47 +0200 +Subject: [PATCH] Build fixes for shared library under bitbake + +Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> +--- + Makefile | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/Makefile b/Makefile +index cd697b1..7918a82 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,5 +1,6 @@ + # Locations of the dependencies + KALDI_ROOT?=$(HOME)/travis/kaldi ++KALDI_LIBS?=$(HOME)/travis/kaldi/libs + OPENFST_ROOT?=$(KALDI_ROOT)/tools/openfst + OPENBLAS_ROOT?=$(KALDI_ROOT)/tools/OpenBLAS/install + MKL_ROOT?=/opt/intel/mkl +@@ -33,7 +34,7 @@ VOSK_HEADERS= \ + vosk_api.h + + CFLAGS=-g -O3 -std=c++17 -Wno-deprecated-declarations -fPIC -DFST_NO_DYNAMIC_LINKING \ +- -I. -I$(KALDI_ROOT)/src -I$(OPENFST_ROOT)/include $(EXTRA_CFLAGS) ++ -I. -I$(KALDI_ROOT) -I$(OPENFST_ROOT) $(EXTRA_CFLAGS) + + LDFLAGS= + +@@ -60,11 +61,11 @@ ifeq ($(USE_SHARED), 0) + $(OPENFST_ROOT)/lib/libfstngram.a + else + LDFLAGS += \ +- -L$(KALDI_ROOT)/libs \ ++ -L$(KALDI_LIBS) \ + -lkaldi-online2 -lkaldi-decoder -lkaldi-ivector -lkaldi-gmm -lkaldi-tree \ + -lkaldi-feat -lkaldi-lat -lkaldi-lm -lkaldi-rnnlm -lkaldi-hmm -lkaldi-nnet3 \ + -lkaldi-transform -lkaldi-cudamatrix -lkaldi-matrix -lkaldi-fstext \ +- -lkaldi-util -lkaldi-base -lfst -lfstngram ++ -lkaldi-util -lkaldi-base -lfst -lfstngram -shared -Wl,-soname,libvosk.so.0.3.42 + endif + + ifeq ($(HAVE_OPENBLAS_CLAPACK), 1) +@@ -76,7 +77,8 @@ ifeq ($(HAVE_OPENBLAS_CLAPACK), 1) + $(OPENBLAS_ROOT)/lib/libblas.a \ + $(OPENBLAS_ROOT)/lib/libf2c.a + else +- LDFLAGS += -lopenblas -llapack -lblas -lf2c ++ LDFLAGS += -lopenblas ++ # -llapack -lblas -lf2c + endif + endif + +@@ -103,10 +105,14 @@ ifeq ($(HAVE_CUDA), 1) + LDFLAGS += -L$(CUDA_ROOT)/lib64 -lcuda -lcublas -lcusparse -lcudart -lcurand -lcufft -lcusolver -lnvToolsExt + endif + +-all: $(OUTDIR)/libvosk.$(EXT) ++all: $(OUTDIR)/libvosk.$(EXT).0.3.42 ++$(OUTDIR)/libvosk.$(EXT).0.3.42: $(OUTDIR)/libvosk.$(EXT) ++ mv libvosk.${EXT} libvosk.${EXT}.0.3.42 ++ ln -sf libvosk.${EXT}.0.3.42 libvosk.so ++ + + $(OUTDIR)/libvosk.$(EXT): $(VOSK_SOURCES:%.cc=$(OUTDIR)/%.o) $(LIBS) +- $(CXX) --shared -s -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) ++ $(CXX) --shared -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) + + $(OUTDIR)/%.o: %.cc $(VOSK_HEADERS) + $(CXX) $(CFLAGS) -c -o $@ $< +-- +2.33.0 + diff --git a/meta-offline-voice-agent/recipes-vosk/vosk/vosk_0.3.42.bb b/meta-offline-voice-agent/recipes-vosk/vosk/vosk_0.3.42.bb new file mode 100644 index 00000000..bf4ffe31 --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk/vosk_0.3.42.bb @@ -0,0 +1,49 @@ +SUMMARY = "Offline open source speech recognition API based on Kaldi and Vosk" +HOMEPAGE = "https://github.com/alphacep/vosk-api" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://../COPYING;md5=d09bbd7a3746b6052fbd78b26a87396b" + +SRC_URI = "git://github.com/alphacep/vosk-api;protocol=https;branch=master \ + file://0001-Build-fixes-for-shared-library-under-bitbake.patch \ + " + +PV = "0.3.42+git${SRCPV}" +SRCREV = "b1b216d4c87d708935f1601287fe502aa11ee4a9" + +S = "${WORKDIR}/git/src" + +DEPENDS += " vosk-kaldi vosk-openfst openblas" + +RDEPENDS:${PN} += " \ +" + +CFLAGS:append = " -I${STAGING_INCDIR}/kaldi -g " +LDFLAGS:remove = "-Wl,--as-needed" + +do_configure(){ + : +} + +do_compile(){ + + make KALDI_ROOT=${STAGING_INCDIR}/kaldi/ OPENFST_ROOT=${STAGING_INCDIR} OPENBLAS_ROOT=${STAGING_INCDIR} USE_SHARED=1 EXTRA_CFLAGS="${CFLAGS}" EXTRA_LDFLAGS="${LDFLAGS}" ${PARALLEL_MAKE} + +} + +do_install(){ + + install -d ${D}${libdir} + install -m 0644 libvosk.so.0.3.42 ${D}${libdir} + cd ${D}${libdir} + ln -sf libvosk.so.0.3.42 libvosk.so + ln -sf libvosk.so.0.3.42 libvosk.so.0 + cd ${S} + + install -d ${D}${includedir}/vosk + for i in *.h ; do + install -m 0644 $i ${D}${includedir}/vosk/ + done + +} + +ERROR_QA:remove = "dev-deps" |