diff --git a/nixos/modules/services/home-automation/wyoming/openwakeword.nix b/nixos/modules/services/home-automation/wyoming/openwakeword.nix index 1b4e932c7b0f..cedca3e7330d 100644 --- a/nixos/modules/services/home-automation/wyoming/openwakeword.nix +++ b/nixos/modules/services/home-automation/wyoming/openwakeword.nix @@ -15,6 +15,7 @@ let mkEnableOption mkIf mkPackageOption + mkRemovedOptionModule types ; @@ -28,8 +29,17 @@ let in { + imports = [ + (mkRemovedOptionModule [ + "services" + "wymoing" + "openwakeword" + "preLoadModels" + ] "Passing a list of models to preload was removed in wyoming-openwakeword 2.0") + ]; + options.services.wyoming.openwakeword = with types; { - enable = mkEnableOption "Wyoming openWakeWord server"; + enable = mkEnableOption "Wyoming protocol server for openWakeWord wake word detection system"; package = mkPackageOption pkgs "wyoming-openwakeword" { }; @@ -50,24 +60,6 @@ in ''; }; - preloadModels = mkOption { - type = listOf str; - default = [ - "ok_nabu" - ]; - example = [ - # wyoming_openwakeword/models/*.tflite - "alexa" - "hey_jarvis" - "hey_mycroft" - "hey_rhasspy" - "ok_nabu" - ]; - description = '' - List of wake word models to preload after startup. - ''; - }; - threshold = mkOption { type = numbers.between 0.0 1.0; default = 0.5; @@ -91,6 +83,16 @@ in apply = toString; }; + refractorySeconds = mkOption { + type = either int float; + default = 2; + example = 1.5; + description = '' + Duration in seconds before a wake word can be detected again. + ''; + apply = toString; + }; + extraArgs = mkOption { type = listOf str; default = [ ]; @@ -125,11 +127,9 @@ in cfg.threshold "--trigger-level" cfg.triggerLevel + "--refractory-seconds" + cfg.refractorySeconds ] - ++ (concatMap (model: [ - "--preload-model" - model - ]) cfg.preloadModels) ++ (concatMap (dir: [ "--custom-model-dir" (toString dir) diff --git a/pkgs/by-name/wy/wyoming-openwakeword/package.nix b/pkgs/by-name/wy/wyoming-openwakeword/package.nix index c1db4c30ad9f..2e626d246c86 100644 --- a/pkgs/by-name/wy/wyoming-openwakeword/package.nix +++ b/pkgs/by-name/wy/wyoming-openwakeword/package.nix @@ -1,26 +1,30 @@ { lib, - python312Packages, + python3Packages, fetchFromGitHub, + fetchpatch, }: -let - # tensorflow-bin unsupported on Python 3.13 - python3Packages = python312Packages; -in - python3Packages.buildPythonApplication rec { pname = "wyoming-openwakeword"; - version = "1.10.0"; + version = "2.0.0"; pyproject = true; src = fetchFromGitHub { owner = "rhasspy"; repo = "wyoming-openwakeword"; rev = "refs/tags/v${version}"; - hash = "sha256-5suYJ+Z6ofVAysoCdHi5b5K0JTYaqeFZ32Cm76wC5LU="; + hash = "sha256-edSZ5W6oSPYLKuxjQerWRkAO/C+WeTiCosNnbS2sbh0="; }; + patches = [ + (fetchpatch { + # Expose entrypoint as wyoming-openwakeword script + url = "https://github.com/rhasspy/wyoming-openwakeword/commit/a8c8419bc65fab07a554aa0925f898a7f3b65d79.patch"; + hash = "sha256-GSViQA01RwkFYEH7CPdU1P0EQ2ml6Vp1OukQ/0VOm+Y="; + }) + ]; + build-system = with python3Packages; [ setuptools ]; @@ -29,12 +33,8 @@ python3Packages.buildPythonApplication rec { "wyoming" ]; - pythonRemoveDeps = [ - "tflite-runtime-nightly" - ]; - dependencies = with python3Packages; [ - tensorflow-bin + pyopen-wakeword wyoming ]; diff --git a/pkgs/development/python-modules/pyopen-wakeword/default.nix b/pkgs/development/python-modules/pyopen-wakeword/default.nix new file mode 100644 index 000000000000..79114e2b493a --- /dev/null +++ b/pkgs/development/python-modules/pyopen-wakeword/default.nix @@ -0,0 +1,56 @@ +{ + lib, + autoPatchelfHook, + buildPythonPackage, + fetchFromGitHub, + setuptools, + numpy, + pytestCheckHook, +}: + +buildPythonPackage rec { + pname = "pyopen-wakeword"; + version = "1.0.1"; + pyproject = true; + + src = fetchFromGitHub { + owner = "rhasspy"; + repo = "pyopen-wakeword"; + tag = "v${version}"; + hash = "sha256-LJ0pHP4nsTx3GPuWUwOwNuXR9tUKABqSHnLSvMlfm1Y="; + }; + + postPatch = '' + python ./script/copy_lib + ''; + + nativeBuildInputs = [ + autoPatchelfHook + ]; + + build-system = [ + setuptools + ]; + + dependencies = [ + numpy + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + pythonImportsCheck = [ + "pyopen_wakeword" + ]; + + meta = { + description = "Alternative Python library for openWakeWord"; + homepage = "https://github.com/rhasspy/pyopen-wakeword"; + changelog = "https://github.com/rhasspy/pyopen-wakeword/blob/${src.tag}/CHANGELOG.md"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ hexa ]; + # vendors prebuilt libtensorflowlite_c.{so,dll,dylib} + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index f8d7e894227f..5309f911b8ca 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -13697,6 +13697,8 @@ self: super: with self; { pyomo = callPackage ../development/python-modules/pyomo { }; + pyopen-wakeword = callPackage ../development/python-modules/pyopen-wakeword/default.nix { }; + pyopencl = callPackage ../development/python-modules/pyopencl { }; pyopengl = callPackage ../development/python-modules/pyopengl {