summaryrefslogtreecommitdiffstats
path: root/meta-offline-voice-agent/recipes-python
diff options
context:
space:
mode:
authoramanarora_09 <aman.arora9848@gmail.com>2022-07-22 15:58:23 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2022-07-28 13:58:18 +0000
commiteda84d25d819824d641cf89af1e4d61a5e946744 (patch)
tree38f4b7c34a5b91257518bcbcdc6b96d24f0641b2 /meta-offline-voice-agent/recipes-python
parentf206eab5753bd9ee2d5b1126c6ec5a18e75cac89 (diff)
meta-offline-voice-agent: Enable layer for offline voice recognition
- This enables offline voice recognition in AGL - Can successfully run vosk API and vosk websocket server Changes: - Create a new layer: meta-offline-voice-recognition - Create recipes for the the Vosk library, API, websocket server and model - Create feature template for the layer (agl-offline-voice-agent) - Add all required packages to IMAGE_INSTALL - ptest enable recipe python3-vosk-api - Few fixes Bug-AGL: SPEC-4497 Change-Id: Icb290ceee22e2c3a51cbd67f7431701795f1201b Signed-off-by: amanarora_09 <aman.arora9848@gmail.com>
Diffstat (limited to 'meta-offline-voice-agent/recipes-python')
-rw-r--r--meta-offline-voice-agent/recipes-python/python3-sounddevice/python3-sounddevice_0.4.4.bb20
-rw-r--r--meta-offline-voice-agent/recipes-python/python3-srt/python3-srt_3.5.2.bb16
-rw-r--r--meta-offline-voice-agent/recipes-python/python3-vosk-websocket-server/python3-vosk-websocket-server_git.bb33
-rw-r--r--meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api/0001-Change-library-search-path-to-usr-lib.patch26
-rw-r--r--meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api/run-ptest3
-rw-r--r--meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api_0.3.42.bb48
6 files changed, 146 insertions, 0 deletions
diff --git a/meta-offline-voice-agent/recipes-python/python3-sounddevice/python3-sounddevice_0.4.4.bb b/meta-offline-voice-agent/recipes-python/python3-sounddevice/python3-sounddevice_0.4.4.bb
new file mode 100644
index 00000000..58d9056d
--- /dev/null
+++ b/meta-offline-voice-agent/recipes-python/python3-sounddevice/python3-sounddevice_0.4.4.bb
@@ -0,0 +1,20 @@
+SUMMARY = "Play and Record Sound with Python"
+HOMEPAGE = "http://python-sounddevice.readthedocs.io/"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=bd8634ff9bb1159041c3d4328659d00f"
+
+SRC_URI = "gitsm://github.com/spatialaudio/python-sounddevice;protocol=https;branch=master"
+
+PV = "0.4.4+git${SRCPV}"
+SRCREV = "a56cdb96c9c8e3d23b877bbcc7d26bd0cda231e0"
+
+S = "${WORKDIR}/git"
+
+inherit setuptools3
+
+# PACKAGECONFIG ?= "numpy"
+PACKAGECONFIG[numpy] = "python3-numpy"
+
+DEPENDS += "python3-cffi-native"
+
+RDEPENDS:${PN} += "portaudio-v19 python3-cffi python3-core python3-ctypes python3-numpy"
diff --git a/meta-offline-voice-agent/recipes-python/python3-srt/python3-srt_3.5.2.bb b/meta-offline-voice-agent/recipes-python/python3-srt/python3-srt_3.5.2.bb
new file mode 100644
index 00000000..258fc521
--- /dev/null
+++ b/meta-offline-voice-agent/recipes-python/python3-srt/python3-srt_3.5.2.bb
@@ -0,0 +1,16 @@
+SUMMARY = "A tiny library for parsing, modifying, and composing SRT files."
+HOMEPAGE = "https://github.com/cdown/srt"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=6658a1272b4469f7249985d28b8697bb"
+
+SRC_URI = "https://files.pythonhosted.org/packages/18/a3/e1466f7c86a9e5d3e462ed6eb3a548917e93cc1ee212cd927f8f4e887ae9/srt-${PV}.tar.gz"
+SRC_URI[md5sum] = "3b68be7c46ec6152123fd801f519a63d"
+SRC_URI[sha256sum] = "7aa4ad5ce4126d3f53b3e7bc4edaa86653d0378bf1c0b1ab8c59f5ab41384450"
+
+S = "${WORKDIR}/srt-${PV}"
+
+inherit setuptools3
+
+RDEPENDS_${PN} += "python3-core python3-datetime python3-logging"
+
+BBCLASSEXTEND = "native nativesdk" \ No newline at end of file
diff --git a/meta-offline-voice-agent/recipes-python/python3-vosk-websocket-server/python3-vosk-websocket-server_git.bb b/meta-offline-voice-agent/recipes-python/python3-vosk-websocket-server/python3-vosk-websocket-server_git.bb
new file mode 100644
index 00000000..1a77f7d2
--- /dev/null
+++ b/meta-offline-voice-agent/recipes-python/python3-vosk-websocket-server/python3-vosk-websocket-server_git.bb
@@ -0,0 +1,33 @@
+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"
+
+RDEPENDS:${PN} += " \
+ vosk \
+ python3-vosk-api \
+ python3-websockets \
+ virtual/vosk-model \
+"
+
+do_configure () {
+ :
+}
+
+do_compile () {
+ :
+}
+
+do_install () {
+ install -d ${D}${bindir}
+ cp ${S}/websocket/asr_server.py ${D}${bindir}/vosk-websocket-python.py
+ chmod a+x ${D}${bindir}/vosk-websocket-python.py
+}
diff --git a/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api/0001-Change-library-search-path-to-usr-lib.patch b/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api/0001-Change-library-search-path-to-usr-lib.patch
new file mode 100644
index 00000000..dd4103d9
--- /dev/null
+++ b/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api/0001-Change-library-search-path-to-usr-lib.patch
@@ -0,0 +1,26 @@
+From 6bbf9272cb367a06a4e4f3303628075df0b51085 Mon Sep 17 00:00:00 2001
+From: amanarora_09 <aman.arora9848@gmail.com>
+Date: Fri, 22 Jul 2022 13:27:07 +0200
+Subject: [PATCH] Change library search path to /usr/lib/
+
+Make the standard location known to the python library.
+
+Signed-off-by: amanarora_09 <aman.arora9848@gmail.com>
+---
+ python/vosk/__init__.py | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/python/vosk/__init__.py b/python/vosk/__init__.py
+index 45e2706..d260c61 100644
+--- a/vosk/__init__.py
++++ b/vosk/__init__.py
+@@ -23,7 +23,8 @@ def open_dll():
+ os.add_dll_directory(dlldir)
+ return _ffi.dlopen(os.path.join(dlldir, "libvosk.dll"))
+ elif sys.platform == 'linux':
+- return _ffi.dlopen(os.path.join(dlldir, "libvosk.so"))
++ dlldir = os.path.abspath("/usr/lib/")
++ return _ffi.dlopen(os.path.join(dlldir, "libvosk.so.0"))
+ elif sys.platform == 'darwin':
+ return _ffi.dlopen(os.path.join(dlldir, "libvosk.dyld"))
+ else:
diff --git a/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api/run-ptest b/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api/run-ptest
new file mode 100644
index 00000000..567af9d7
--- /dev/null
+++ b/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api/run-ptest
@@ -0,0 +1,3 @@
+#!/bin/sh
+cd tests/
+./test_simple.py test.wav
diff --git a/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api_0.3.42.bb b/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api_0.3.42.bb
new file mode 100644
index 00000000..ba15bd56
--- /dev/null
+++ b/meta-offline-voice-agent/recipes-python/python3-vosk/python3-vosk-api_0.3.42.bb
@@ -0,0 +1,48 @@
+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-Change-library-search-path-to-usr-lib.patch \
+ file://run-ptest \
+ "
+
+PV = "0.3.42+git${SRCPV}"
+SRCREV = "b1b216d4c87d708935f1601287fe502aa11ee4a9"
+
+S = "${WORKDIR}/git/python"
+
+inherit setuptools3 ptest
+
+DEPENDS += " \
+ python3-srt-native \
+ python3-tqdm-native \
+ python3-requests-native \
+ python3-pip-native \
+ python3-charset-normalizer-native \
+"
+
+RDEPENDS:${PN} += " \
+ python3-cffi \
+ python3-compression \
+ python3-core \
+ python3-datetime \
+ python3-json \
+ python3-logging \
+ python3-misc \
+ python3-multiprocessing \
+ python3-netclient \
+ python3-requests \
+ python3-tqdm \
+ python3-srt \
+ python3-charset-normalizer \
+ python3-sounddevice \
+ virtual/vosk-model \
+"
+
+do_install_ptest () {
+ install -d ${D}${PTEST_PATH}/tests/
+ cp ${S}/example/test_simple.py ${D}${PTEST_PATH}/tests/
+ cp ${S}/example/test.wav ${D}${PTEST_PATH}/tests/
+}