Skip to content

Commit

Permalink
nixos/wyoming-faster-whisper: Update for 2.4.0
Browse files Browse the repository at this point in the history
- Refresh the description for models to include all possible options
- Add option for the initial prompt
- Allow selecting Cantonese (yue) as language
- Change the default beam size to 0 (auto)
- Rework the commandline
  • Loading branch information
mweinelt committed Jan 13, 2025
1 parent f428101 commit 17337bd
Showing 1 changed file with 72 additions and 14 deletions.
86 changes: 72 additions & 14 deletions nixos/modules/services/home-automation/wyoming/faster-whisper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
config,
lib,
pkgs,
utils,
...
}:

Expand All @@ -20,6 +21,10 @@ let
toString
;

inherit (utils)
escapeSystemdExecArgs
;

in

{
Expand All @@ -29,7 +34,7 @@ in
servers = mkOption {
default = { };
description = ''
Attribute set of faster-whisper instances to spawn.
Attribute set of wyoming-faster-whisper instances to spawn.
'';
type = types.attrsOf (
types.submodule (
Expand All @@ -43,9 +48,33 @@ in
default = "tiny-int8";
example = "Systran/faster-distil-whisper-small.en";
description = ''
Name of the voice model to use.
Name of the voice model to use. Can also be a HuggingFace model ID or a path to
a custom model directory.
Check the [2.0.0 release notes](https://github.com/rhasspy/wyoming-faster-whisper/releases/tag/v2.0.0) for possible values.
Compressed models (`int8`) are slightly less accurate, but smaller and faster.
Available models:
- `tiny-int8` (compressed)
- `tiny`
- `tiny.en` (English only)
- `base-int8` (compressed)
- `base`
- `base.en` (English only)
- `small-int8` (compressed)
- `distil-small.en` (distilled, English only)
- `small`
- `small.en` (English only)
- `medium-int8` (compressed)
- `distil-medium.en` (distilled, English only)
- `medium`
- `medium.en` (English only)
- `large`
- `large-v1`
- `distil-large-v2` (distilled, English only)
- `large-v2`
- `distil-large-v3` (distilled, English only)
- `large-v3`
- `turbo` (faster than large-v3)
'';
};

Expand Down Expand Up @@ -171,6 +200,7 @@ in
"uz"
"vi"
"yi"
"yue"
"yo"
"zh"
];
Expand All @@ -180,12 +210,26 @@ in
'';
};

initialPrompt = mkOption {
type = nullOr str;
default = null;
example = ''
The following conversation takes place in the universe of Wizard of Oz. Key terms include 'Yellow Brick Road' (the path to follow), 'Emerald City' (the ultimate goal), and 'Ruby Slippers' (the magical tools to succeed). Keep these in mind as they guide the journey.
'';
description = ''
Optional text to provide as a prompt for the first window. This can be used to provide, or
"prompt-engineer" a context for transcription, e.g. custom vocabularies or proper nouns
to make it more likely to predict those word correctly.
'';
};

beamSize = mkOption {
type = ints.unsigned;
default = 1;
default = 0;
example = 5;
description = ''
The number of beams to use in beam search.
Use `0` to automatically select a value based on the CPU.
'';
apply = toString;
};
Expand Down Expand Up @@ -235,16 +279,30 @@ in
User = "wyoming-faster-whisper";
StateDirectory = "wyoming/faster-whisper";
# https://github.com/home-assistant/addons/blob/master/whisper/rootfs/etc/s6-overlay/s6-rc.d/whisper/run
ExecStart = ''
${cfg.package}/bin/wyoming-faster-whisper \
--data-dir $STATE_DIRECTORY \
--download-dir $STATE_DIRECTORY \
--uri ${options.uri} \
--device ${options.device} \
--model ${options.model} \
--language ${options.language} \
--beam-size ${options.beamSize} ${options.extraArgs}
'';
ExecStart = escapeSystemdExecArgs (
[
(lib.getExe cfg.package)
"--data-dir"
"/var/lib/wyoming/faster-whisper"
"--download-dir"
"/var/lib/wyoming/faster-whisper/models"
"--uri"
options.uri
"--device"
options.device
"--model"
options.model
"--language"
options.language
"--beam-size"
options.beamSize
]
++ lib.optionals (options.initialPrompt != null) [
"--initial-prompt"
options.initialPrompt
]
++ options.extraArgs
);
CapabilityBoundingSet = "";
DeviceAllow =
if
Expand Down

0 comments on commit 17337bd

Please sign in to comment.