Remove OpenAI's Whisper AI and its dependencies 63/30363/4
authorAnuj Solanki <anuj603362@gmail.com>
Mon, 30 Sep 2024 21:39:02 +0000 (23:39 +0200)
committerAnuj Solanki <anuj603362@gmail.com>
Sun, 6 Oct 2024 14:25:15 +0000 (16:25 +0200)
 - Remove OpenAI's Whisper AI recipes  and all its dependencies.
 - Add recipes for whisper-cpp, whisper-cpp-base and whisper-cpp-tiny
   model.
 - Add recipe for python-mpd.
 - Add voice-agent-config to /etc/default and update config path in
   agl-service-voiceagent.service

Bug-AGL: SPEC-5200
Change-Id: Iaebd9c46930144b41659710202e9b737dbe9f60b
Signed-off-by: Anuj Solanki <anuj603362@gmail.com>
40 files changed:
meta-offline-voice-agent/licenses/LICENSE
meta-offline-voice-agent/recipes-assistant/voiceagent-app/flutter-voiceassistant_git.bb
meta-offline-voice-agent/recipes-assistant/voiceagent-service/agl-service-voiceagent_git.bb
meta-offline-voice-agent/recipes-assistant/voiceagent-service/files/agl-service-voiceagent.service
meta-offline-voice-agent/recipes-assistant/voiceagent-service/files/voice-agent-config.ini [new file with mode: 0644]
meta-offline-voice-agent/recipes-python/python3-python-mpd2/python3-python-mpd2_3.1.1.bb [new file with mode: 0644]
meta-offline-voice-agent/recipes-whisper/whisper-cpp-model/whisper-cpp-base.bb [new file with mode: 0644]
meta-offline-voice-agent/recipes-whisper/whisper-cpp-model/whisper-cpp-tiny.bb [new file with mode: 0644]
meta-offline-voice-agent/recipes-whisper/whisper-cpp/whisper-cpp_git.bb [new file with mode: 0644]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/files/0001-Add-new-DG2-device-IDs-194.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/files/0001-Add-new-DG2-device-IDs-194.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/files/0001-BiF-CMakeLists.txt-remove-opt-from-DEPENDS.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/files/0001-BiF-CMakeLists.txt-remove-opt-from-DEPENDS.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/files/0001-Introduce-ARL-H-support-172.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/files/0001-Introduce-ARL-H-support-172.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/files/0001-external-SPIRV-Tools-change-path-to-tools-and-header.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/files/0001-external-SPIRV-Tools-change-path-to-tools-and-header.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/files/0001-fix-tblgen.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/files/0001-fix-tblgen.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/files/0003-Improve-Reproducibility-for-src-package.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/files/0003-Improve-Reproducibility-for-src-package.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/files/intel-oneapi-runtime.conf [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/files/intel-oneapi-runtime.conf with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/gmmlib_22.3.15.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/gmmlib_22.3.15.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/intel-compute-runtime/allow-to-find-cpp-generation-tool.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/intel-compute-runtime/allow-to-find-cpp-generation-tool.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/intel-compute-runtime/disable-werror.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/intel-compute-runtime/disable-werror.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/intel-compute-runtime/external-ocloc.patch [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/intel-compute-runtime/external-ocloc.patch with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/intel-compute-runtime_24.13.29138.7.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/intel-compute-runtime_24.13.29138.7.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/intel-graphics-compiler_1.0.16510.2.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/intel-graphics-compiler_1.0.16510.2.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/intel-oneapi-dpcpp-cpp-runtime_2024.0.0-49819.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/intel-oneapi-dpcpp-cpp-runtime_2024.0.0-49819.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/intel-oneapi-dpcpp-cpp_2024.0.0-49819.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/intel-oneapi-dpcpp-cpp_2024.0.0-49819.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/intel-oneapi-mkl_2024.0.0-49656.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/intel-oneapi-mkl_2024.0.0-49656.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/level-zero_1.15.8.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/level-zero_1.15.8.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/onednn.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/onednn.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/onednn/run-ptest [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/onednn/run-ptest with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-devtools/recipes-intel/setup-intel-oneapi-env_2023.0.0-25370.bb [moved from meta-offline-voice-agent/recipes-devtools/recipes-intel/setup-intel-oneapi-env_2023.0.0-25370.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-python/llvmlite/files/LICENSE [moved from meta-offline-voice-agent/recipes-python/llvmlite/files/LICENSE with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-python/llvmlite/llvmlite_0.43.0.bb [moved from meta-offline-voice-agent/recipes-python/llvmlite/llvmlite_0.43.0.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-python/numba/python3-numba_%.bbappend [moved from meta-offline-voice-agent/recipes-python/numba/python3-numba_%.bbappend with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-python/pytorch/python3-pytorch_%.bbappend [moved from meta-offline-voice-agent/recipes-python/pytorch/python3-pytorch_%.bbappend with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-python/tiktoken/python3-tiktoken-crates.inc [moved from meta-offline-voice-agent/recipes-python/tiktoken/python3-tiktoken-crates.inc with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-python/tiktoken/python3-tiktoken_0.7.0.bb [moved from meta-offline-voice-agent/recipes-python/tiktoken/python3-tiktoken_0.7.0.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-whisper/whisper-model/openai-whisper-base.bb [moved from meta-offline-voice-agent/recipes-whisper/whisper-model/openai-whisper-base.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-whisper/whisper-model/openai-whisper-tiny.bb [moved from meta-offline-voice-agent/recipes-whisper/whisper-model/openai-whisper-tiny.bb with 100% similarity]
meta-offline-voice-agent/unused-whisper-ai-recipes/recipes-whisper/whisper/whisper_git.bb [moved from meta-offline-voice-agent/recipes-whisper/whisper/whisper_git.bb with 100% similarity]
templates/feature/agl-offline-voice-agent/50_bblayers.conf.inc
templates/feature/agl-offline-voice-agent/50_local.conf.inc

index d255525..aee97e2 100644 (file)
@@ -1,6 +1,7 @@
+
 MIT License
 
-Copyright (c) 2022 OpenAI
+Copyright (c) 2023-2024 The ggml authors
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
index 6726379..cdb9d3d 100644 (file)
@@ -32,4 +32,5 @@ do_install:append() {
     install -D -m 0644 ${WORKDIR}/agl-app-flutter@flutter_voiceassistant.service ${D}${systemd_system_unitdir}/agl-app-flutter@flutter_voiceassistant.service
 }
 
+
 FILES:${PN} += "${datadir} "
index e1f1cc5..aedab00 100644 (file)
@@ -1,11 +1,12 @@
 SUMMARY = "A gRPC-based voice agent service designed for Automotive Grade Linux (AGL)."
-HOMEPAGE = "https://github.com/malik727/agl-service-voiceagent"
+.HOMEPAGE = "https://github.com/malik727/agl-service-voiceagent"
 LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=4202492ed9afcab3aaecc4a9ec32adb2"
 
 SRC_URI = " \
-    file://agl-service-voiceagent.service \
     git://gerrit.automotivelinux.org/gerrit/apps/agl-service-voiceagent;protocol=https;branch=${AGL_BRANCH} \
+    file://agl-service-voiceagent.service \
+    file://voice-agent-config.ini \
 "
 
 SRCREV = "${AUTOREV}"
@@ -15,7 +16,7 @@ S = "${WORKDIR}/git"
 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"
+WAKE_WORD ?= "hey automotive"
 
 DEPENDS += " \
     python3 \
@@ -53,8 +54,12 @@ do_install:append() {
     # 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}
+        install -m 0644 ${WORKDIR}/agl-service-voiceagent.service ${D}${systemd_system_unitdir}/agl-service-voiceagent.service
     fi
+
+    # Copy config file to etc/default
+    install -d ${D}/etc/default/
+    cp -R ${WORKDIR}/voice-agent-config.ini ${D}/etc/default/
 }
 
 RDEPENDS:${PN} += " \
@@ -65,7 +70,8 @@ RDEPENDS:${PN} += " \
     kuksa-client \
     python3-snips-inference-agl \
     vosk \
-    whisper \
+    whisper-cpp \
+    python3-python-mpd2 \
     "
 
-FILES:${PN} += "/usr/share/nlu/"
+FILES:${PN} += "/usr/share/nlu/ /etc/default/"
index b4d738f..af08b42 100644 (file)
@@ -3,7 +3,7 @@ Description=AGL Voice Agent Service
 After=network.target
 
 [Service]
-ExecStart=/usr/bin/voiceagent-service run-server --default
+ExecStart=/usr/bin/voiceagent-service run-server --config /etc/default/voice-agent-config.ini
 Restart=always
 
 [Install]
diff --git a/meta-offline-voice-agent/recipes-assistant/voiceagent-service/files/voice-agent-config.ini b/meta-offline-voice-agent/recipes-assistant/voiceagent-service/files/voice-agent-config.ini
new file mode 100644 (file)
index 0000000..e4f6313
--- /dev/null
@@ -0,0 +1,46 @@
+[General]
+base_audio_dir = /usr/share/nlu/commands/
+vosk_model_path = /usr/share/vosk/vosk-model-small-en-us-0.15/
+whisper_model_path = /usr/share/whisper/tiny.pt
+whisper_cpp_path = /usr/bin/whisper-cpp
+whisper_cpp_model_path = /usr/share/whisper-cpp/models/tiny.en.bin
+wake_word_model_path = /usr/share/vosk/vosk-model-small-en-us-0.15/
+snips_model_path = /usr/share/nlu/snips/model/
+channels = 1
+sample_rate = 16000
+bits_per_sample = 16
+wake_word = hey automotive
+server_port = 51053
+server_address = 127.0.0.1
+rasa_model_path = /usr/share/nlu/rasa/models/
+rasa_server_port = 51054
+rasa_detached_mode = 1
+base_log_dir = /usr/share/nlu/logs/
+store_voice_commands = 0
+online_mode = 0
+online_mode_address = 65.108.107.216
+online_mode_port = 50051
+online_mode_timeout = 15
+mpd_ip = 127.0.0.1
+mpd_port = 6600
+
+[Kuksa]
+ip = 127.0.0.1
+port = 55555
+protocol = grpc
+insecure = 0
+token =  /usr/lib/python3.12/site-packages/kuksa_certificates/jwt/super-admin.json.token
+tls_server_name = Server
+
+[VSS]
+hostname = localhost
+port = 55555
+protocol = grpc
+insecure = 0
+token_filename = /etc/xdg/AGL/agl-vss-helper/agl-vss-helper.token
+ca_cert_filename = /etc/kuksa-val/CA.pem
+tls_server_name = Server
+
+[Mapper]
+intents_vss_map = /usr/share/nlu/mappings/intents_vss_map.json
+vss_signals_spec = /usr/share/nlu/mappings/vss_signals_spec.json
diff --git a/meta-offline-voice-agent/recipes-python/python3-python-mpd2/python3-python-mpd2_3.1.1.bb b/meta-offline-voice-agent/recipes-python/python3-python-mpd2/python3-python-mpd2_3.1.1.bb
new file mode 100644 (file)
index 0000000..bca98bb
--- /dev/null
@@ -0,0 +1,15 @@
+SUMMARY = "A Python MPD client library"
+HOMEPAGE = "https://github.com/Mic92/python-mpd2"
+AUTHOR = "Joerg Thalheim <joerg@thalheim.io>"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e6a600fd5e1d9cbde2d983680233ad02"
+
+SRC_URI = "https://files.pythonhosted.org/packages/53/be/e77206eb35eb37ccd3506fba237e1431431d04c482707730ce2a6802e95c/python-mpd2-3.1.1.tar.gz"
+SRC_URI[md5sum] = "b218d6f233c23da0bc82c372308bbf8d"
+SRC_URI[sha256sum] = "4baec3584cc43ed9948d5559079fafc2679b06b2ade273e909b3582654b2b3f5"
+
+S = "${WORKDIR}/python-mpd2-3.1.1"
+
+RDEPENDS_${PN} = ""
+
+inherit setuptools3
diff --git a/meta-offline-voice-agent/recipes-whisper/whisper-cpp-model/whisper-cpp-base.bb b/meta-offline-voice-agent/recipes-whisper/whisper-cpp-model/whisper-cpp-base.bb
new file mode 100644 (file)
index 0000000..621eb78
--- /dev/null
@@ -0,0 +1,15 @@
+SUMMARY = "Whisper-cpp base model"
+HOMEPAGE = "https://github.com/ggerganov/whisper.cpp"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${THISDIR}/../../licenses/LICENSE;md5=7a3cb84505132167069a95fa683a011c"
+
+SRC_URI = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin"
+SRC_URI[sha256sum] = "60ed5bc3dd14eea856493d334349b405782ddcaf0028d4b5df4088345fba2efe"
+
+do_install() {
+    # Install the models
+    install -d ${D}${datadir}/whisper-cpp/models
+    install -m 0644 ${WORKDIR}/ggml-base.bin ${D}${datadir}/whisper-cpp/models/base.bin
+}
+
+FILES:${PN} += " /usr /usr/share /usr/share/whisper-cpp/* "
diff --git a/meta-offline-voice-agent/recipes-whisper/whisper-cpp-model/whisper-cpp-tiny.bb b/meta-offline-voice-agent/recipes-whisper/whisper-cpp-model/whisper-cpp-tiny.bb
new file mode 100644 (file)
index 0000000..7e4b70f
--- /dev/null
@@ -0,0 +1,15 @@
+SUMMARY = "Whisper-cpp base model"
+HOMEPAGE = "https://github.com/ggerganov/whisper.cpp"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${THISDIR}/../../licenses/LICENSE;md5=7a3cb84505132167069a95fa683a011c"
+
+SRC_URI = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin"
+SRC_URI[sha256sum] = "921e4cf8686fdd993dcd081a5da5b6c365bfde1162e72b08d75ac75289920b1f"
+
+do_install() {
+    # Install the models
+    install -d ${D}${datadir}/whisper-cpp/models
+    install -m 0644 ${WORKDIR}/ggml-tiny.en.bin ${D}${datadir}/whisper-cpp/models/tiny.en.bin
+}
+
+FILES:${PN} += " /usr /usr/share /usr/share/whisper-cpp/* "
diff --git a/meta-offline-voice-agent/recipes-whisper/whisper-cpp/whisper-cpp_git.bb b/meta-offline-voice-agent/recipes-whisper/whisper-cpp/whisper-cpp_git.bb
new file mode 100644 (file)
index 0000000..0e3e9a1
--- /dev/null
@@ -0,0 +1,39 @@
+DESCRIPTION = "Whisper.cpp - Port of OpenAI's Whisper model in C++ for faster and smaller inference"
+HOMEPAGE = "https://github.com/ggerganov/whisper.cpp"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=1539dadbedb60aa18519febfeab70632"
+
+SRC_URI = "git://github.com/ggerganov/whisper.cpp.git;protocol=https;branch=master"
+
+SRCREV = "81c999fe0a25c4ebbfef10ed8a1a96df9cfc10fd"
+
+DEPENDS = "ffmpeg openblas"
+
+S = "${WORKDIR}/git"
+
+inherit cmake
+
+do_configure:prepend() {
+    sed -i 's/-march=native//g' ${S}/Makefile
+    sed -i 's/-mtune=native//g' ${S}/Makefile
+}
+
+
+# Specify the model you want to download
+WHISPER_MODEL ?= "base.en"
+
+do_compile() {
+    export CXXFLAGS="${CXXFLAGS} -I${STAGING_INCDIR}/openblas"
+    export LDFLAGS="${LDFLAGS} -lopenblas"
+    cd ${S}
+    oe_runmake GGML_OPENBLAS=1
+}
+
+do_install() {
+    # Install the main binary
+    install -d ${D}${bindir}
+    install -m 0755 ${S}/main ${D}${bindir}/whisper-cpp
+}
+
+FILES_${PN} += "${datadir}/whisper-cpp/models/* ${datadir}/* ${bindir}/* /usr/share "
+RDEPENDS:${PN} += "openblas ffmpeg"
index 5c235ac..959b603 100644 (file)
@@ -10,3 +10,6 @@ BBLAYERS =+ " \
 # package in meta-oe is newer
 BBMASK += "meta-tensorflow/recipes-devtools/python/python3-gast_0.4.0.bb"
 
+# needed for rasa
+#      ${METADIR}/external/meta-tensorflow \
+#
index 632f14b..f0c6221 100644 (file)
@@ -21,17 +21,22 @@ FEATURE_PACKAGES_agl-offline-voice-agent:append = " \
     python3-sounddevice \
     flutter-voiceassistant \
     agl-service-voiceagent \
-    whisper \
-    openai-whisper-base \
+    whisper-cpp \
+    whisper-cpp-tiny \
     "
 
 EXTRA_IMAGE_FEATURES += "agl-offline-voice-agent"
 
 PREFERRED_RPROVIDER_vosk-model ?= "vosk-model-small-en-us"
-PREFERRED_RPROVIDER_whisper-model ?= "openai-whisper-base"
+PREFERRED_RPROVIDER_whisper-model ?= "whisper-cpp-tiny"
 
 # bump bazel limits
 BAZEL_JOBS = "HOST_CPUS*.4"
 BAZEL_MEM = "HOST_RAM*.4"
 
 LICENSE_FLAGS_ACCEPTED += "commercial_ffmpeg"
+
+# no rasa support currently
+#      python3-rasa \
+#      rasa-model-agl \
+#
\ No newline at end of file