nixos-configs/modules/wyoming-plus/default.nix
matt1432 ab8efa64c5
All checks were successful
Discord / discord commits (push) Has been skipped
feat(hass): support VAD for wakeword
2024-12-20 02:29:24 -05:00

52 lines
1.4 KiB
Nix

{
config,
lib,
pkgs,
...
}: let
inherit (lib) getExe mkOption types;
inherit (lib.modules) mkForce mkIf mkOverride;
inherit (lib.strings) concatMapStringsSep concatStringsSep;
cfg = config.services.wyoming;
in {
options.services.wyoming.openwakeword.vadThreshold = mkOption {
type = types.float;
default = 0.0;
apply = toString;
};
config = let
forkedPkg = pkgs.callPackage ./pkgs {};
in {
systemd.services = mkIf (cfg.openwakeword.enable) {
wyoming-openwakeword.serviceConfig = {
MemoryDenyWriteExecute = mkForce (cfg.openwakeword.package != forkedPkg);
# changes according to https://github.com/rhasspy/wyoming-openwakeword/pull/27
ExecStart = mkForce (concatStringsSep " " [
(getExe cfg.openwakeword.package)
"--uri ${cfg.openwakeword.uri}"
"--threshold ${cfg.openwakeword.threshold}"
"--vad-threshold ${cfg.openwakeword.vadThreshold}"
"--trigger-level ${cfg.openwakeword.triggerLevel}"
(concatMapStringsSep " "
(dir: "--custom-model-dir ${toString dir}")
cfg.openwakeword.customModelsDirectories)
(concatMapStringsSep " "
(model: "--preload-model ${model}")
cfg.openwakeword.preloadModels)
cfg.openwakeword.extraArgs
]);
};
};
services.wyoming.openwakeword = mkIf (cfg.openwakeword.enable) {
package = mkOverride 900 forkedPkg;
};
};
}