nixos/wyoming/openwakeword: update for 1.8.1

Remove the deprecated --models option, as models are now discovered
and loaded dynamically from all configured model dirs at runtime.

Allow setting up custom model directories, so wake words other than the
built-in ones can be used, e.g. from
https://github.com/fwartner/home-assistant-wakewords-collection.
This commit is contained in:
Martin Weinelt 2023-10-30 17:57:48 +01:00
parent 48e6ac6d4f
commit e458280606
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759

View File

@ -8,6 +8,7 @@ let
cfg = config.services.wyoming.openwakeword;
inherit (lib)
concatStringsSep
concatMapStringsSep
escapeShellArgs
mkOption
@ -15,6 +16,7 @@ let
mkEnableOption
mkIf
mkPackageOptionMD
mkRemovedOptionModule
types
;
@ -25,6 +27,10 @@ let
in
{
imports = [
(mkRemovedOptionModule [ "services" "wyoming" "openwakeword" "models" ] "Configuring models has been removed, they are now dynamically discovered and loaded at runtime")
];
meta.buildDocsInSandbox = false;
options.services.wyoming.openwakeword = with types; {
@ -41,18 +47,11 @@ in
'';
};
models = mkOption {
type = listOf str;
default = [
# wyoming_openwakeword/models/*.tflite
"alexa"
"hey_jarvis"
"hey_mycroft"
"hey_rhasspy"
"ok_nabu"
];
description = mdDoc ''
List of wake word models that should be made available.
customModelsDirectories = mkOption {
type = listOf types.path;
default = [];
description = lib.mdDoc ''
Paths to directories with custom wake word models (*.tflite model files).
'';
};
@ -61,6 +60,14 @@ in
default = [
"ok_nabu"
];
example = [
# wyoming_openwakeword/models/*.tflite
"alexa"
"hey_jarvis"
"hey_mycroft"
"hey_rhasspy"
"ok_nabu"
];
description = mdDoc ''
List of wake word models to preload after startup.
'';
@ -112,14 +119,15 @@ in
DynamicUser = true;
User = "wyoming-openwakeword";
# https://github.com/home-assistant/addons/blob/master/openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/run
ExecStart = ''
${cfg.package}/bin/wyoming-openwakeword \
--uri ${cfg.uri} \
${concatMapStringsSep " " (model: "--model ${model}") cfg.models} \
${concatMapStringsSep " " (model: "--preload-model ${model}") cfg.preloadModels} \
--threshold ${cfg.threshold} \
--trigger-level ${cfg.triggerLevel} ${cfg.extraArgs}
'';
ExecStart = concatStringsSep " " [
"${cfg.package}/bin/wyoming-openwakeword"
"--uri ${cfg.uri}"
(concatMapStringsSep " " (model: "--preload-model ${model}") cfg.preloadModels)
(concatMapStringsSep " " (dir: "--custom-model-dir ${toString dir}") cfg.customModelDirectories)
"--threshold ${cfg.threshold}"
"--trigger-level ${cfg.triggerLevel}"
"${cfg.extraArgs}"
];
CapabilityBoundingSet = "";
DeviceAllow = "";
DevicePolicy = "closed";