From 64889c4c525c4c66fb74dd703a1cbc0375bc405d Mon Sep 17 00:00:00 2001 From: Malik Talha Date: Thu, 2 Nov 2023 03:29:04 +0500 Subject: Update voice agent related recipes Change the SRCURI to use gerrit repos. Update agl-service-voicegent recipe to correctly package all the required content. Add recipe for another en-us vosk model. Add service files for RASA and Voice Agent server. Bug-AGL: SPEC-4906 Change-Id: Ic9f77386ff5c545c2a80433dd538c94bd8763e9e Signed-off-by: Malik Talha --- .../agl-flutter-voiceassistant_git.bb | 27 --------------- .../voiceagent-app/flutter-voiceassistant_git.bb | 28 ++++++++++++++++ .../agl-service-voiceagent_git.bb | 39 ++++++++++++++++++++-- .../files/agl-service-voiceagent.service | 11 ++++++ .../recipes-nlu/nlu-model/rasa-model-agl_0.1.0.bb | 3 +- .../recipes-nlu/nlu-model/snips-model-agl_0.2.0.bb | 3 +- .../python3-rasa/files/rasa-service.service | 10 ++++++ .../python3-rasa/python3-rasa_3.6.4.bb | 11 +++++- .../python3-snips-inference-agl_0.2.0.bb | 5 ++- .../python3-snips-nlu-utils_0.9.1.bb | 2 +- .../vosk-model/vosk-model-en-us_0.22.bb | 22 ++++++++++++ .../agl-offline-voice-agent/50_local.conf.inc | 3 +- 12 files changed, 125 insertions(+), 39 deletions(-) delete mode 100644 meta-offline-voice-agent/recipes-assistant/voiceagent-app/agl-flutter-voiceassistant_git.bb create mode 100644 meta-offline-voice-agent/recipes-assistant/voiceagent-app/flutter-voiceassistant_git.bb create mode 100644 meta-offline-voice-agent/recipes-assistant/voiceagent-service/files/agl-service-voiceagent.service create mode 100644 meta-offline-voice-agent/recipes-python/python3-rasa/files/rasa-service.service create mode 100644 meta-offline-voice-agent/recipes-vosk/vosk-model/vosk-model-en-us_0.22.bb diff --git a/meta-offline-voice-agent/recipes-assistant/voiceagent-app/agl-flutter-voiceassistant_git.bb b/meta-offline-voice-agent/recipes-assistant/voiceagent-app/agl-flutter-voiceassistant_git.bb deleted file mode 100644 index 036e1fe6..00000000 --- a/meta-offline-voice-agent/recipes-assistant/voiceagent-app/agl-flutter-voiceassistant_git.bb +++ /dev/null @@ -1,27 +0,0 @@ -SUMMARY = "AGL Voice Assistant" -DESCRIPTION = "Offline voice assistant app designed for Automotive Grade Linux (AGL)." -HOMEPAGE = "https://github.com/malik727/agl-flutter-voiceassistant" -BUGTRACKER = "https://github.com/malik727/agl-flutter-voiceassistant/issues" -SECTION = "graphics" -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=4202492ed9afcab3aaecc4a9ec32adb2" - -SRC_URI = "git://github.com/malik727/agl-flutter-voiceassistant.git;protocol=https;branch=main \ - " - -SRCREV = "${AUTOREV}" -S = "${WORKDIR}/git" - -inherit agl-app flutter-app - -# flutter-app -############# -PUBSPEC_APPNAME = "agl_flutter_voiceassistant" -FLUTTER_APPLICATION_INSTALL_PREFIX = "/flutter" -FLUTTER_BUILD_ARGS = "bundle -v" - -# agl-app -######### -AGL_APP_TEMPLATE = "agl-app-flutter" -AGL_APP_ID = "agl_flutter_voiceassistant" -AGL_APP_NAME = "AGL Voice Assistant" \ No newline at end of file diff --git a/meta-offline-voice-agent/recipes-assistant/voiceagent-app/flutter-voiceassistant_git.bb b/meta-offline-voice-agent/recipes-assistant/voiceagent-app/flutter-voiceassistant_git.bb new file mode 100644 index 00000000..edcb9fe4 --- /dev/null +++ b/meta-offline-voice-agent/recipes-assistant/voiceagent-app/flutter-voiceassistant_git.bb @@ -0,0 +1,28 @@ +SUMMARY = "Voice Assistant" +DESCRIPTION = "Offline voice assistant app designed for Automotive Grade Linux (AGL)." +HOMEPAGE = "https://github.com/malik727/agl-flutter-voiceassistant" +BUGTRACKER = "https://github.com/malik727/agl-flutter-voiceassistant/issues" +SECTION = "graphics" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=4202492ed9afcab3aaecc4a9ec32adb2" + +SRC_URI = "\ + git://gerrit.automotivelinux.org/gerrit/apps/flutter-speechrecognition-demo;protocol=https;branch=${AGL_BRANCH} \ + " + +SRCREV = "${AUTOREV}" +S = "${WORKDIR}/git" + +inherit agl-app flutter-app + +# flutter-app +############# +PUBSPEC_APPNAME = "flutter_voiceassistant" +FLUTTER_APPLICATION_INSTALL_PREFIX = "/flutter" +FLUTTER_BUILD_ARGS = "bundle -v" + +# agl-app +######### +AGL_APP_TEMPLATE = "agl-app-flutter" +AGL_APP_ID = "flutter_voiceassistant" +AGL_APP_NAME = "Voice Assistant" \ No newline at end of file diff --git a/meta-offline-voice-agent/recipes-assistant/voiceagent-service/agl-service-voiceagent_git.bb b/meta-offline-voice-agent/recipes-assistant/voiceagent-service/agl-service-voiceagent_git.bb index 615ec64f..6fa560cc 100644 --- a/meta-offline-voice-agent/recipes-assistant/voiceagent-service/agl-service-voiceagent_git.bb +++ b/meta-offline-voice-agent/recipes-assistant/voiceagent-service/agl-service-voiceagent_git.bb @@ -4,23 +4,56 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=4202492ed9afcab3aaecc4a9ec32adb2" SRC_URI = " \ - git://github.com/malik727/agl-service-voiceagent;protocol=https;branch=main \ + file://agl-service-voiceagent.service \ + git://gerrit.automotivelinux.org/gerrit/apps/agl-service-voiceagent;protocol=https;branch=${AGL_BRANCH} " SRCREV = "${AUTOREV}" S = "${WORKDIR}/git" +# Speech to Text Model Name, use 'vosk-model-en-us-0.22' for better performance +VOSK_STT_MODEL_NAME ?= "vosk-model-small-en-us-0.15" +# Wake Word Detection Model Name +VOSK_WWD_MODEL_NAME ?= "vosk-model-small-en-us-0.15" +WAKE_WORD ?= "hello auto" + DEPENDS += " \ python3 \ python3-setuptools-native \ python3-grpcio-tools-native \ " -inherit setuptools3 +inherit setuptools3 systemd + +SYSTEMD_SERVICE:${PN} = "agl-service-voiceagent.service" do_compile:prepend() { # Generate proto files and move them to 'generated/' directory python3 -m grpc_tools.protoc -I${S}/agl_service_voiceagent/protos --python_out=${S}/agl_service_voiceagent/generated --grpc_python_out=${S}/agl_service_voiceagent/generated voice_agent.proto + + # Replace all placeholders with actual values + sed -i 's|PYTHON_DIR|${PYTHON_SITEPACKAGES_DIR}|g' ${S}/agl_service_voiceagent/config.ini + sed -i 's|VOSK_STT_MODEL_NAME|${VOSK_STT_MODEL_NAME}|g' ${S}/agl_service_voiceagent/config.ini + sed -i 's|VOSK_WWD_MODEL_NAME|${VOSK_WWD_MODEL_NAME}|g' ${S}/agl_service_voiceagent/config.ini + sed -i 's|WAKE_WORD_VALUE|${WAKE_WORD}|g' ${S}/agl_service_voiceagent/config.ini + + # Keep Note that if you make any change to the value of above variables, you'll need to perform: + # 'bitbake -c cleanall agl-service-voiceagent' + # and compile this package again to see your changes reflected. +} + +do_install:append() { + # Create the destination directory if it doesn't exist + install -d ${D}/usr/share/nlu/ + + # Copy the 'mappings' folder to the destination directory + cp -R ${WORKDIR}/git/mappings ${D}/usr/share/nlu/ + + # Initialize our service definition + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${WORKDIR}/agl-service-voiceagent.service ${D}${systemd_system_unitdir} + fi } RDEPENDS:${PN} += " \ @@ -33,3 +66,5 @@ RDEPENDS:${PN} += " \ python3-snips-inference-agl \ vosk \ " + +FILES:${PN} += "/usr/share/nlu/" \ No newline at end of file diff --git a/meta-offline-voice-agent/recipes-assistant/voiceagent-service/files/agl-service-voiceagent.service b/meta-offline-voice-agent/recipes-assistant/voiceagent-service/files/agl-service-voiceagent.service new file mode 100644 index 00000000..54139431 --- /dev/null +++ b/meta-offline-voice-agent/recipes-assistant/voiceagent-service/files/agl-service-voiceagent.service @@ -0,0 +1,11 @@ +[Unit] +Description=AGL Voice Agent Service +After=network.target +Requires=rasa-service.service + +[Service] +ExecStart=/usr/bin/voiceagent-service run-server --default +Restart=always + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/meta-offline-voice-agent/recipes-nlu/nlu-model/rasa-model-agl_0.1.0.bb b/meta-offline-voice-agent/recipes-nlu/nlu-model/rasa-model-agl_0.1.0.bb index 38e37406..52fd992f 100644 --- a/meta-offline-voice-agent/recipes-nlu/nlu-model/rasa-model-agl_0.1.0.bb +++ b/meta-offline-voice-agent/recipes-nlu/nlu-model/rasa-model-agl_0.1.0.bb @@ -4,10 +4,9 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=2e01060a5557fe6a4b57f5ea6dc048d9" SRC_URI = " \ - git://github.com/malik727/rasa-model-agl;protocol=https;branch=main \ + git://gerrit.automotivelinux.org/gerrit/src/rasa-model-agl;protocol=https;branch=${AGL_BRANCH} \ " -PV = "1.0.0+git${SRCPV}" SRCREV = "${AUTOREV}" S = "${WORKDIR}/git" diff --git a/meta-offline-voice-agent/recipes-nlu/nlu-model/snips-model-agl_0.2.0.bb b/meta-offline-voice-agent/recipes-nlu/nlu-model/snips-model-agl_0.2.0.bb index 6d191baf..ed15232d 100644 --- a/meta-offline-voice-agent/recipes-nlu/nlu-model/snips-model-agl_0.2.0.bb +++ b/meta-offline-voice-agent/recipes-nlu/nlu-model/snips-model-agl_0.2.0.bb @@ -4,10 +4,9 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=ecab3ce0771d366e0f8e4ca058eb48e7" SRC_URI = " \ - git://github.com/malik727/snips-model-agl.git;protocol=https;branch=main \ + git://gerrit.automotivelinux.org/gerrit/src/snips-model-agl;protocol=https;branch=${AGL_BRANCH} \ " -PV = "1.0.0+git${SRCPV}" SRCREV = "${AUTOREV}" S = "${WORKDIR}/git" diff --git a/meta-offline-voice-agent/recipes-python/python3-rasa/files/rasa-service.service b/meta-offline-voice-agent/recipes-python/python3-rasa/files/rasa-service.service new file mode 100644 index 00000000..7d91032c --- /dev/null +++ b/meta-offline-voice-agent/recipes-python/python3-rasa/files/rasa-service.service @@ -0,0 +1,10 @@ +[Unit] +Description=RASA Service +After=network.target + +[Service] +ExecStart=/usr/bin/rasa run --enable-api -m /usr/share/nlu/rasa/models/ -p 51054 +Restart=always + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/meta-offline-voice-agent/recipes-python/python3-rasa/python3-rasa_3.6.4.bb b/meta-offline-voice-agent/recipes-python/python3-rasa/python3-rasa_3.6.4.bb index 1038fc36..d55e8cbe 100644 --- a/meta-offline-voice-agent/recipes-python/python3-rasa/python3-rasa_3.6.4.bb +++ b/meta-offline-voice-agent/recipes-python/python3-rasa/python3-rasa_3.6.4.bb @@ -6,12 +6,15 @@ LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=930bc50f846c55c70b79b78055ae3d9b" PYPI_PACKAGE = "rasa" SRC_URI += " \ + file://rasa-service.service \ file://0001-rasa-remove-group-from-poetry-as-its-not-supported.patch \ " SRC_URI[md5sum] = "7aab346588a3056b54ff783357e4d081" SRC_URI[sha256sum] = "21e57a99bdec8d9f36f7828985c8e3fb3bf3b2c3c94a856d3006e0a68b41a399" -inherit pypi python_poetry_core +inherit pypi python_poetry_core systemd + +SYSTEMD_SERVICE:${PN} = "rasa-service.service" RDEPENDS:${PN} += " \ python3-requests \ @@ -78,4 +81,10 @@ do_install:append() { # it causes conflicts. rm -f ${D}${libdir}/python3.10/site-packages/README.md rm -f ${D}${libdir}/python3.10/site-packages/LICENSE.txt + + # Initialize our service definition + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${WORKDIR}/rasa-service.service ${D}${systemd_system_unitdir} + fi } diff --git a/meta-offline-voice-agent/recipes-python/python3-snips-inference/python3-snips-inference-agl_0.2.0.bb b/meta-offline-voice-agent/recipes-python/python3-snips-inference/python3-snips-inference-agl_0.2.0.bb index df18ac53..3f993c74 100644 --- a/meta-offline-voice-agent/recipes-python/python3-snips-inference/python3-snips-inference-agl_0.2.0.bb +++ b/meta-offline-voice-agent/recipes-python/python3-snips-inference/python3-snips-inference-agl_0.2.0.bb @@ -4,12 +4,11 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=ecab3ce0771d366e0f8e4ca058eb48e7" SRC_URI += " \ - git://github.com/malik727/snips-inference-agl.git;protocol=https;branch=main \ + git://gerrit.automotivelinux.org/gerrit/src/snips-inference-agl;protocol=https;branch=${AGL_BRANCH} \ " -PV = "0.2.0+git${SRCPV}" +SRCREV = "${AUTOREV}" S = "${WORKDIR}/git" -SRCREV = "6d45b8d814b1937251524dd8a1e8cac0d8cab5de" DEPENDS += " \ python3-setuptools-native \ diff --git a/meta-offline-voice-agent/recipes-python/python3-snips-inference/python3-snips-nlu-utils_0.9.1.bb b/meta-offline-voice-agent/recipes-python/python3-snips-inference/python3-snips-nlu-utils_0.9.1.bb index 491e4633..d0bc55e7 100644 --- a/meta-offline-voice-agent/recipes-python/python3-snips-inference/python3-snips-nlu-utils_0.9.1.bb +++ b/meta-offline-voice-agent/recipes-python/python3-snips-inference/python3-snips-nlu-utils_0.9.1.bb @@ -4,7 +4,7 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://../LICENSE;md5=fdebc354a9200f9dc847e624d4584ea9" SRC_URI += " \ - git://github.com/malik727/snips-nlu-utils.git;protocol=https;branch=master \ + git://github.com/snipsco/snips-nlu-utils.git;protocol=https;branch=master \ " PV = "0.9.1+git${SRCPV}" diff --git a/meta-offline-voice-agent/recipes-vosk/vosk-model/vosk-model-en-us_0.22.bb b/meta-offline-voice-agent/recipes-vosk/vosk-model/vosk-model-en-us_0.22.bb new file mode 100644 index 00000000..16f6ab3d --- /dev/null +++ b/meta-offline-voice-agent/recipes-vosk/vosk-model/vosk-model-en-us_0.22.bb @@ -0,0 +1,22 @@ +SUMMARY = "Lightweight wideband model 'en-us' 0.22" +HOMEPAGE = "https://alphacephei.com/vosk/" +LICENSE = "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-en-us-0.22.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] = "1ff7bf86a1243a98be7964040a7c569ade4e70f8b5e815b1edb5f3a74ca5f567" + +do_install() { + install -d ${D}/usr/share/vosk + cp -R ${WORKDIR}/vosk-model-en-us-0.22/ ${D}/usr/share/vosk/ +} + +FILES:${PN} += " /usr/share/vosk /usr/share/vosk/vosk-model-en-us-0.22 " + +RPROVIDES:${PN} += "virtual/vosk-model" diff --git a/templates/feature/agl-offline-voice-agent/50_local.conf.inc b/templates/feature/agl-offline-voice-agent/50_local.conf.inc index fa46907c..95bc4365 100644 --- a/templates/feature/agl-offline-voice-agent/50_local.conf.inc +++ b/templates/feature/agl-offline-voice-agent/50_local.conf.inc @@ -19,7 +19,8 @@ IMAGE_INSTALL:append = " \ python3-vosk-api \ python3-vosk-websocket-server \ python3-sounddevice \ - flutter-vosk-demo \ + flutter-voiceassistant \ + agl-service-voiceagent \ " PREFERRED_PROVIDER_virtual/vosk-model ?= "vosk-model-small-en-us" -- cgit 1.2.3-korg