9 cfg = config.services.wyoming.faster-whisper;
26 options.services.wyoming.faster-whisper = with types; {
27 package = mkPackageOption pkgs "wyoming-faster-whisper" { };
32 Attribute set of faster-whisper instances to spawn.
34 type = types.attrsOf (
39 enable = mkEnableOption "Wyoming faster-whisper server";
43 default = "tiny-int8";
44 example = "Systran/faster-distil-whisper-small.en";
46 Name of the voice model to use.
48 Check the [2.0.0 release notes](https://github.com/rhasspy/wyoming-faster-whisper/releases/tag/v2.0.0) for possible values.
53 type = strMatching "^(tcp|unix)://.*$";
54 example = "tcp://0.0.0.0:10300";
56 URI to bind the wyoming server to.
61 # https://opennmt.net/CTranslate2/python/ctranslate2.models.Whisper.html#
69 Determines the platform faster-whisper is run on. CPU works everywhere, CUDA requires a compatible NVIDIA GPU.
75 # https://github.com/home-assistant/addons/blob/master/whisper/config.yaml#L20
179 The language used to to parse words and sentences.
183 beamSize = mkOption {
184 type = ints.unsigned;
188 The number of beams to use in beam search.
193 extraArgs = mkOption {
197 Extra arguments to pass to the server commandline.
199 apply = escapeShellArgs;
216 mkIf (cfg.servers != { }) {
217 systemd.services = mapAttrs' (
219 nameValuePair "wyoming-faster-whisper-${server}" {
220 inherit (options) enable;
221 description = "Wyoming faster-whisper server instance ${server}";
223 "network-online.target"
226 "network-online.target"
231 # https://github.com/rhasspy/wyoming-faster-whisper/issues/27
232 environment."HF_HUB_CACHE" = "/tmp";
235 User = "wyoming-faster-whisper";
236 StateDirectory = "wyoming/faster-whisper";
237 # https://github.com/home-assistant/addons/blob/master/whisper/rootfs/etc/s6-overlay/s6-rc.d/whisper/run
239 ${cfg.package}/bin/wyoming-faster-whisper \
240 --data-dir $STATE_DIRECTORY \
241 --download-dir $STATE_DIRECTORY \
242 --uri ${options.uri} \
243 --device ${options.device} \
244 --model ${options.model} \
245 --language ${options.language} \
246 --beam-size ${options.beamSize} ${options.extraArgs}
248 CapabilityBoundingSet = "";
251 builtins.elem options.device [
257 # https://docs.nvidia.com/dgx/pdf/dgx-os-5-user-guide.pdf
259 "char-nvidia-frontend"
265 DevicePolicy = "closed";
266 LockPersonality = true;
267 MemoryDenyWriteExecute = true;
270 ProtectHostname = true;
271 ProtectKernelLogs = true;
272 ProtectKernelModules = true;
273 ProtectKernelTunables = true;
274 ProtectControlGroups = true;
275 ProtectProc = "invisible";
277 RestrictAddressFamilies = [
282 RestrictNamespaces = true;
283 RestrictRealtime = true;
284 SystemCallArchitectures = "native";