Skip to content

Commit c20f9f1

Browse files
committed
Add voxtype wrapper module
This adds a wrapper module for voxtype. The user `settings` are merged into the `defaultSettings` as voxtype will crash without some defaults set. A check make sure the default at least parses the config without error. I had to update the nixpkgs input as voxtype was only added recently.
1 parent 241f2f7 commit c20f9f1

File tree

3 files changed

+103
-3
lines changed

3 files changed

+103
-3
lines changed

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/voxtype/check.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
pkgs,
3+
self,
4+
}:
5+
6+
let
7+
voxtypeWrapped =
8+
(self.wrapperModules.voxtype.apply {
9+
inherit pkgs;
10+
}).wrapper;
11+
in
12+
pkgs.runCommand "voxtype-test" { } ''
13+
# this will fail, if the default config is off
14+
"${voxtypeWrapped}/bin/voxtype" config
15+
touch $out
16+
''

modules/voxtype/module.nix

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
config,
3+
lib,
4+
wlib,
5+
...
6+
}:
7+
let
8+
tomlFmt = config.pkgs.formats.toml { };
9+
defaultSettings = {
10+
hotkey = { };
11+
audio = {
12+
device = "default";
13+
sample_rate = 16000;
14+
max_duration_secs = 60;
15+
};
16+
output = {
17+
mode = "type";
18+
};
19+
};
20+
in
21+
{
22+
_class = "wrapper";
23+
options = {
24+
settings = lib.mkOption {
25+
type = tomlFmt.type;
26+
default = defaultSettings;
27+
description = ''
28+
Configuration of voxtype.
29+
Default has all minimally required options set.`
30+
'';
31+
example =
32+
let
33+
pkgs = config.pkgs;
34+
in
35+
{
36+
engine = "parakeet";
37+
parakeet.model =
38+
let
39+
parakeetBaseUrl = "https://huggingface.co/istupakov/parakeet-tdt-0.6b-v3-onnx/resolve/main";
40+
in
41+
pkgs.linkFarm "parakeet-tdt-0.6b-v3" [
42+
{
43+
name = "encoder-model.onnx";
44+
path = pkgs.fetchurl {
45+
url = "${parakeetBaseUrl}/encoder-model.int8.onnx";
46+
hash = "sha256-YTnS+n4bCGCXsnfHFJcl7bq4nMfHrmSyPHQb5AVa/wk=";
47+
};
48+
}
49+
{
50+
name = "decoder_joint-model.onnx";
51+
path = pkgs.fetchurl {
52+
url = "${parakeetBaseUrl}/decoder_joint-model.int8.onnx";
53+
hash = "sha256-7qdIPuPRowN12u3I7YPjlgyRsJiBISeg2Z0ciXdmenA=";
54+
};
55+
}
56+
{
57+
name = "vocab.txt";
58+
path = pkgs.fetchurl {
59+
url = "${parakeetBaseUrl}/vocab.txt";
60+
hash = "sha256-1YVEZ56kvGrFY9H1Ret9R0vWz6Rn8KbiwdwcfTfjw10=";
61+
};
62+
}
63+
{
64+
name = "config.json";
65+
path = pkgs.fetchurl {
66+
url = "${parakeetBaseUrl}/config.json";
67+
hash = "sha256-ZmkDx2uXmMrywhCv1PbNYLCKjb+YAOyNejvA0hSKxGY=";
68+
};
69+
}
70+
];
71+
hotkey.enabled = false;
72+
};
73+
};
74+
"voxtype.toml" = lib.mkOption {
75+
type = wlib.types.file config.pkgs;
76+
default.path = tomlFmt.generate "voxtype.toml" (defaultSettings // config.settings);
77+
};
78+
};
79+
config.flags = {
80+
"--config" = toString config."voxtype.toml".path;
81+
};
82+
config.package = config.pkgs.voxtype;
83+
config.meta.maintainers = [ lib.maintainers.lenny ];
84+
}

0 commit comments

Comments
 (0)