feat(hass): support VAD for wakeword
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
a393d11e1c
commit
ab8efa64c5
7 changed files with 56 additions and 168 deletions
|
@ -62,7 +62,12 @@
|
||||||
uri = "tcp://127.0.0.1:10400";
|
uri = "tcp://127.0.0.1:10400";
|
||||||
|
|
||||||
threshold = 0.55;
|
threshold = 0.55;
|
||||||
|
vadThreshold = 0.50;
|
||||||
|
|
||||||
customModelsDirectories = ["${wakewords-src}/en/yo_homie"];
|
customModelsDirectories = ["${wakewords-src}/en/yo_homie"];
|
||||||
|
preloadModels = ["yo_homie"];
|
||||||
|
|
||||||
|
extraArgs = ["--debug"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,20 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
inherit (lib) getExe mkOption types;
|
||||||
inherit (lib.modules) mkForce mkIf mkOverride;
|
inherit (lib.modules) mkForce mkIf mkOverride;
|
||||||
inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString;
|
inherit (lib.strings) concatMapStringsSep concatStringsSep;
|
||||||
|
|
||||||
cfg = config.services.wyoming;
|
cfg = config.services.wyoming;
|
||||||
in {
|
in {
|
||||||
|
options.services.wyoming.openwakeword.vadThreshold = mkOption {
|
||||||
|
type = types.float;
|
||||||
|
default = 0.0;
|
||||||
|
apply = toString;
|
||||||
|
};
|
||||||
|
|
||||||
config = let
|
config = let
|
||||||
forkedPkg = (import ./pkgs {inherit pkgs;}).wyoming-openwakeword;
|
forkedPkg = pkgs.callPackage ./pkgs {};
|
||||||
in {
|
in {
|
||||||
systemd.services = mkIf (cfg.openwakeword.enable) {
|
systemd.services = mkIf (cfg.openwakeword.enable) {
|
||||||
wyoming-openwakeword.serviceConfig = {
|
wyoming-openwakeword.serviceConfig = {
|
||||||
|
@ -18,26 +25,22 @@ in {
|
||||||
|
|
||||||
# changes according to https://github.com/rhasspy/wyoming-openwakeword/pull/27
|
# changes according to https://github.com/rhasspy/wyoming-openwakeword/pull/27
|
||||||
ExecStart = mkForce (concatStringsSep " " [
|
ExecStart = mkForce (concatStringsSep " " [
|
||||||
"${cfg.openwakeword.package}/bin/wyoming-openwakeword"
|
(getExe cfg.openwakeword.package)
|
||||||
|
|
||||||
"--uri ${cfg.openwakeword.uri}"
|
"--uri ${cfg.openwakeword.uri}"
|
||||||
"--threshold ${cfg.openwakeword.threshold}"
|
"--threshold ${cfg.openwakeword.threshold}"
|
||||||
|
"--vad-threshold ${cfg.openwakeword.vadThreshold}"
|
||||||
|
"--trigger-level ${cfg.openwakeword.triggerLevel}"
|
||||||
|
|
||||||
(concatMapStringsSep " "
|
(concatMapStringsSep " "
|
||||||
(dir: "--custom-model-dir ${toString dir}")
|
(dir: "--custom-model-dir ${toString dir}")
|
||||||
cfg.openwakeword.customModelsDirectories)
|
cfg.openwakeword.customModelsDirectories)
|
||||||
|
|
||||||
# removed option https://github.com/rhasspy/wyoming-openwakeword/pull/27#issuecomment-2211822998
|
(concatMapStringsSep " "
|
||||||
(optionalString
|
(model: "--preload-model ${model}")
|
||||||
(cfg.openwakeword.package != forkedPkg)
|
cfg.openwakeword.preloadModels)
|
||||||
(concatMapStringsSep " " (model: "--preload-model ${model}") cfg.openwakeword.preloadModels))
|
|
||||||
|
|
||||||
# removed option since preloading was removed
|
cfg.openwakeword.extraArgs
|
||||||
(optionalString
|
|
||||||
(cfg.openwakeword.package != forkedPkg)
|
|
||||||
"--trigger-level ${cfg.openwakeword.triggerLevel}")
|
|
||||||
|
|
||||||
"${cfg.openwakeword.extraArgs}"
|
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,19 +1,38 @@
|
||||||
{pkgs, ...}: let
|
{
|
||||||
python3Packages = pkgs.python311Packages;
|
lib,
|
||||||
in rec {
|
fetchFromGitHub,
|
||||||
speexdsp-ns = pkgs.callPackage ./speexdsp-ns.nix {
|
onnxruntime,
|
||||||
inherit python3Packages;
|
python3Packages,
|
||||||
|
wyoming-openwakeword,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) makeLibraryPath;
|
||||||
|
in
|
||||||
|
wyoming-openwakeword.overridePythonAttrs (o: {
|
||||||
|
version = o.version + "-vad";
|
||||||
|
|
||||||
|
# https://github.com/rhasspy/wyoming-openwakeword/pull/17
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "rhasspy";
|
||||||
|
repo = "wyoming-openwakeword";
|
||||||
|
rev = "8e679a592f5862d67a7b688d3f711b468e4b1f93";
|
||||||
|
hash = "sha256-sP0i2ghcTpuuZbVTsAFw527y2oaJIH9OolQtKjkYC2E=";
|
||||||
};
|
};
|
||||||
|
|
||||||
tflite-runtime = pkgs.callPackage ./tflite-runtime.nix {
|
buildInputs =
|
||||||
inherit python3Packages;
|
(o.buildInputs or [])
|
||||||
};
|
++ [onnxruntime];
|
||||||
|
|
||||||
openwakeword = pkgs.callPackage ./openwakeword.nix {
|
propagatedBuildInputs =
|
||||||
inherit python3Packages speexdsp-ns tflite-runtime;
|
(o.propagatedBuildInputs or [])
|
||||||
};
|
++ [python3Packages.onnxruntime];
|
||||||
|
|
||||||
wyoming-openwakeword = pkgs.callPackage ./wyoming-openwakeword.nix {
|
# Native onnxruntime lib used by Python module onnxruntime can't find its other libs without this
|
||||||
inherit openwakeword python3Packages;
|
makeWrapperArgs = [
|
||||||
};
|
''--prefix LD_LIBRARY_PATH : "${makeLibraryPath [onnxruntime]}"''
|
||||||
}
|
];
|
||||||
|
|
||||||
|
postFixup = ''
|
||||||
|
cp -ar ./wyoming_openwakeword/models/silero_vad.onnx $out/lib/python*/site-packages/wyoming_openwakeword/models
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
{
|
|
||||||
fetchFromGitHub,
|
|
||||||
python3Packages,
|
|
||||||
speexdsp-ns,
|
|
||||||
tflite-runtime,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (builtins) attrValues;
|
|
||||||
in
|
|
||||||
python3Packages.buildPythonApplication rec {
|
|
||||||
pname = "openwakeword";
|
|
||||||
version = "0.6.0";
|
|
||||||
pyproject = true;
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "dscripka";
|
|
||||||
repo = "openWakeWord";
|
|
||||||
rev = "v${version}";
|
|
||||||
hash = "sha256-QsXV9REAHdP0Y0fVZuU+Gt9+gcPMB60bc3DOMDYuaDM=";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = with python3Packages; [
|
|
||||||
setuptools
|
|
||||||
];
|
|
||||||
|
|
||||||
propagatedBuildInputs = attrValues {
|
|
||||||
inherit
|
|
||||||
(python3Packages)
|
|
||||||
onnxruntime
|
|
||||||
tqdm
|
|
||||||
scipy
|
|
||||||
scikit-learn
|
|
||||||
requests
|
|
||||||
;
|
|
||||||
|
|
||||||
inherit
|
|
||||||
speexdsp-ns
|
|
||||||
tflite-runtime
|
|
||||||
;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
fetchFromGitHub,
|
|
||||||
python3Packages,
|
|
||||||
speexdsp,
|
|
||||||
swig,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
python3Packages.buildPythonApplication {
|
|
||||||
pname = "speexdsp-ns";
|
|
||||||
version = "0.1.2";
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "TeaPoly";
|
|
||||||
repo = "speexdsp-ns-python";
|
|
||||||
rev = "8af784a230e23f4eeaa4a58111774ad0864b1f0b";
|
|
||||||
hash = "sha256-9IGhHZBlDYfGygB+fAdEDp7qeIEOWBsiLZAUFTVBxG0=";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = [swig];
|
|
||||||
propagatedBuildInputs = [speexdsp];
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
fetchurl,
|
|
||||||
python3Packages,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
python3Packages.buildPythonApplication {
|
|
||||||
pname = "tflite-runtime";
|
|
||||||
format = "wheel";
|
|
||||||
version = "2.14.0";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://files.pythonhosted.org/packages/8f/a6/02d68cb62cd221589a0ff055073251d883936237c9c990e34a1d7cecd06f/tflite_runtime-2.14.0-cp311-cp311-manylinux2014_x86_64.whl";
|
|
||||||
hash = "sha256-GVq3UuflcymmjlTdPdVDn62Ii5v/G+Dw3AQqMjepDk0=";
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
This package uses a `wyoming-openwakeword` fork that makes use of
|
|
||||||
the upstream `openwakeword` instead of a fork: https://github.com/rhasspy/wyoming-openwakeword/pull/27
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
lib,
|
|
||||||
fetchFromGitHub,
|
|
||||||
onnxruntime,
|
|
||||||
openwakeword,
|
|
||||||
python3Packages,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib) attrValues makeLibraryPath;
|
|
||||||
in
|
|
||||||
python3Packages.buildPythonApplication {
|
|
||||||
pname = "wyoming-openwakeword";
|
|
||||||
version = "1.10.0-unstable";
|
|
||||||
pyproject = true;
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "rhasspy";
|
|
||||||
repo = "wyoming-openwakeword";
|
|
||||||
rev = "324d669645a778439c5392d9e287a763ead3cf4c";
|
|
||||||
hash = "sha256-69oR2LHiUfx8j39nWp7XhG5xTvmOoPCLjSlH1CFvavo=";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = attrValues {
|
|
||||||
inherit
|
|
||||||
(python3Packages)
|
|
||||||
setuptools
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
pythonRelaxDeps = [
|
|
||||||
"wyoming"
|
|
||||||
];
|
|
||||||
|
|
||||||
propagatedBuildInputs = attrValues {
|
|
||||||
inherit
|
|
||||||
(python3Packages)
|
|
||||||
wyoming
|
|
||||||
;
|
|
||||||
|
|
||||||
inherit openwakeword;
|
|
||||||
};
|
|
||||||
|
|
||||||
pythonImportsCheck = [
|
|
||||||
"wyoming_openwakeword"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Native onnxruntime lib used by Python module onnxruntime can't find its other libs without this
|
|
||||||
makeWrapperArgs = [
|
|
||||||
''--prefix LD_LIBRARY_PATH : "${makeLibraryPath [onnxruntime]}"''
|
|
||||||
];
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
description = "Open source voice assistant toolkit for many human languages";
|
|
||||||
homepage = "https://github.com/rhasspy/wyoming-openwakeword";
|
|
||||||
license = lib.licenses.mit;
|
|
||||||
mainProgram = "wyoming-openwakeword";
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue