Unverified Commit e4582806 authored by Martin Weinelt's avatar Martin Weinelt
Browse files

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.
parent 48e6ac6d
Loading
Loading
Loading
Loading
+27 −19
Original line number Diff line number Diff line
@@ -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,9 +47,20 @@ in
      '';
    };

    models = mkOption {
    customModelsDirectories = mkOption {
      type = listOf types.path;
      default = [];
      description = lib.mdDoc ''
        Paths to directories with custom wake word models (*.tflite model files).
      '';
    };

    preloadModels = mkOption {
      type = listOf str;
      default = [
        "ok_nabu"
      ];
      example = [
        # wyoming_openwakeword/models/*.tflite
        "alexa"
        "hey_jarvis"
@@ -51,16 +68,6 @@ in
        "hey_rhasspy"
        "ok_nabu"
      ];
      description = mdDoc ''
        List of wake word models that should be made available.
      '';
    };

    preloadModels = mkOption {
      type = listOf str;
      default = [
        "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";