2024-09-05 08:48:42 -04:00
|
|
|
{
|
2024-09-01 19:19:30 -04:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2024-12-20 02:29:24 -05:00
|
|
|
inherit (lib) getExe mkOption types;
|
2024-10-10 13:11:11 -04:00
|
|
|
inherit (lib.modules) mkForce mkIf mkOverride;
|
2024-12-20 02:29:24 -05:00
|
|
|
inherit (lib.strings) concatMapStringsSep concatStringsSep;
|
2024-09-01 19:19:30 -04:00
|
|
|
|
2024-09-12 18:21:31 -04:00
|
|
|
cfg = config.services.wyoming;
|
2024-09-01 19:19:30 -04:00
|
|
|
in {
|
2024-12-20 02:29:24 -05:00
|
|
|
options.services.wyoming.openwakeword.vadThreshold = mkOption {
|
|
|
|
type = types.float;
|
|
|
|
default = 0.0;
|
|
|
|
apply = toString;
|
|
|
|
};
|
|
|
|
|
2024-09-12 18:21:31 -04:00
|
|
|
config = let
|
2024-12-20 02:29:24 -05:00
|
|
|
forkedPkg = pkgs.callPackage ./pkgs {};
|
2024-09-12 18:21:31 -04:00
|
|
|
in {
|
2024-12-15 10:45:06 -05:00
|
|
|
systemd.services = mkIf (cfg.openwakeword.enable) {
|
|
|
|
wyoming-openwakeword.serviceConfig = {
|
|
|
|
MemoryDenyWriteExecute = mkForce (cfg.openwakeword.package != forkedPkg);
|
2024-09-12 18:21:31 -04:00
|
|
|
|
2024-12-15 10:45:06 -05:00
|
|
|
# changes according to https://github.com/rhasspy/wyoming-openwakeword/pull/27
|
|
|
|
ExecStart = mkForce (concatStringsSep " " [
|
2024-12-20 02:29:24 -05:00
|
|
|
(getExe cfg.openwakeword.package)
|
2024-09-12 18:21:31 -04:00
|
|
|
|
2024-12-15 10:45:06 -05:00
|
|
|
"--uri ${cfg.openwakeword.uri}"
|
|
|
|
"--threshold ${cfg.openwakeword.threshold}"
|
2024-12-20 02:29:24 -05:00
|
|
|
"--vad-threshold ${cfg.openwakeword.vadThreshold}"
|
|
|
|
"--trigger-level ${cfg.openwakeword.triggerLevel}"
|
2024-09-12 18:21:31 -04:00
|
|
|
|
2024-12-15 10:45:06 -05:00
|
|
|
(concatMapStringsSep " "
|
|
|
|
(dir: "--custom-model-dir ${toString dir}")
|
|
|
|
cfg.openwakeword.customModelsDirectories)
|
2024-09-12 18:21:31 -04:00
|
|
|
|
2024-12-20 02:29:24 -05:00
|
|
|
(concatMapStringsSep " "
|
|
|
|
(model: "--preload-model ${model}")
|
|
|
|
cfg.openwakeword.preloadModels)
|
2024-09-12 18:21:31 -04:00
|
|
|
|
2024-12-20 02:29:24 -05:00
|
|
|
cfg.openwakeword.extraArgs
|
2024-12-15 10:45:06 -05:00
|
|
|
]);
|
2024-09-01 19:19:30 -04:00
|
|
|
};
|
2024-12-15 10:45:06 -05:00
|
|
|
};
|
2024-09-12 18:21:31 -04:00
|
|
|
|
|
|
|
services.wyoming.openwakeword = mkIf (cfg.openwakeword.enable) {
|
|
|
|
package = mkOverride 900 forkedPkg;
|
2024-09-01 19:19:30 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|