8 cfg = config.services.wyoming.faster-whisper;
25 options.services.wyoming.faster-whisper = with types; {
26 package = mkPackageOption pkgs "wyoming-faster-whisper" { };
31 Attribute set of faster-whisper instances to spawn.
33 type = types.attrsOf (types.submodule (
36 enable = mkEnableOption "Wyoming faster-whisper server";
40 default = "tiny-int8";
41 example = "Systran/faster-distil-whisper-small.en";
43 Name of the voice model to use.
45 Check the [2.0.0 release notes](https://github.com/rhasspy/wyoming-faster-whisper/releases/tag/v2.0.0) for possible values.
50 type = strMatching "^(tcp|unix)://.*$";
51 example = "tcp://0.0.0.0:10300";
53 URI to bind the wyoming server to.
58 # https://opennmt.net/CTranslate2/python/ctranslate2.models.Whisper.html#
66 Determines the platform faster-whisper is run on. CPU works everywhere, CUDA requires a compatible NVIDIA GPU.
72 # https://github.com/home-assistant/addons/blob/master/whisper/config.yaml#L20
73 "auto" "af" "am" "ar" "as" "az" "ba" "be" "bg" "bn" "bo" "br" "bs" "ca" "cs" "cy" "da" "de" "el" "en" "es" "et" "eu" "fa" "fi" "fo" "fr" "gl" "gu" "ha" "haw" "he" "hi" "hr" "ht" "hu" "hy" "id" "is" "it" "ja" "jw" "ka" "kk" "km" "kn" "ko" "la" "lb" "ln" "lo" "lt" "lv" "mg" "mi" "mk" "ml" "mn" "mr" "ms" "mt" "my" "ne" "nl" "nn" "no" "oc" "pa" "pl" "ps" "pt" "ro" "ru" "sa" "sd" "si" "sk" "sl" "sn" "so" "sq" "sr" "su" "sv" "sw" "ta" "te" "tg" "th" "tk" "tl" "tr" "tt" "uk" "ur" "uz" "vi" "yi" "yo" "zh"
77 The language used to to parse words and sentences.
86 The number of beams to use in beam search.
91 extraArgs = mkOption {
95 Extra arguments to pass to the server commandline.
97 apply = escapeShellArgs;
111 in mkIf (cfg.servers != {}) {
112 systemd.services = mapAttrs' (server: options:
113 nameValuePair "wyoming-faster-whisper-${server}" {
114 inherit (options) enable;
115 description = "Wyoming faster-whisper server instance ${server}";
117 "network-online.target"
120 "network-online.target"
125 # https://github.com/rhasspy/wyoming-faster-whisper/issues/27
126 environment."HF_HUB_CACHE" = "/tmp";
129 User = "wyoming-faster-whisper";
130 StateDirectory = "wyoming/faster-whisper";
131 # https://github.com/home-assistant/addons/blob/master/whisper/rootfs/etc/s6-overlay/s6-rc.d/whisper/run
133 ${cfg.package}/bin/wyoming-faster-whisper \
134 --data-dir $STATE_DIRECTORY \
135 --download-dir $STATE_DIRECTORY \
136 --uri ${options.uri} \
137 --device ${options.device} \
138 --model ${options.model} \
139 --language ${options.language} \
140 --beam-size ${options.beamSize} ${options.extraArgs}
142 CapabilityBoundingSet = "";
143 DeviceAllow = if builtins.elem options.device [ "cuda" "auto" ] then [
144 # https://docs.nvidia.com/dgx/pdf/dgx-os-5-user-guide.pdf
145 # CUDA not working? Check DeviceAllow and PrivateDevices first!
151 "/dev/nvidia-caps/nvidia-cap1"
152 "/dev/nvidia-caps/nvidia-cap2"
154 "/dev/nvidia-modeset"
156 "/dev/nvidia-uvm-tools"
158 DevicePolicy = "closed";
159 LockPersonality = true;
160 MemoryDenyWriteExecute = true;
163 ProtectHostname = true;
164 ProtectKernelLogs = true;
165 ProtectKernelModules = true;
166 ProtectKernelTunables = true;
167 ProtectControlGroups = true;
168 ProtectProc = "invisible";
170 RestrictAddressFamilies = [
175 RestrictNamespaces = true;
176 RestrictRealtime = true;
177 SystemCallArchitectures = "native";