Skip to content

Commit

Permalink
add voice option to home-assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
ibizaman authored and ibizaman committed Dec 17, 2024
1 parent 796fdea commit a8b29b2
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
40 changes: 40 additions & 0 deletions modules/services/home-assistant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,42 @@ in
};
};

voice = lib.mkOption {
description = "Options related to voice service.";
default = {};
type = lib.types.submodule {
options = {
speech-to-text = lib.mkOption {
description = ''
Wyoming piper servers.
https://search.nixos.org/options?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=services.wyoming.piper.servers
'';
type = lib.types.attrsOf lib.types.anything;
default = {};
};
text-to-speech = lib.mkOption {
description = ''
Wyoming faster-whisper servers.
https://search.nixos.org/options?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=services.wyoming.faster-whisper.servers
'';
type = lib.types.attrsOf lib.types.anything;
default = {};
};
wakeword = lib.mkOption {
description = ''
Wyoming open wakework servers.
https://search.nixos.org/options?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=services.wyoming.openwakeword
'';
type = lib.types.anything;
default = { enable = false; };
};
};
};
};

backup = lib.mkOption {
description = ''
Backup configuration.
Expand Down Expand Up @@ -267,6 +303,10 @@ in
};
};

services.wyoming.piper.servers = cfg.voice.text-to-speech;
services.wyoming.faster-whisper.servers = cfg.voice.speech-to-text;
services.wyoming.openwakeword = cfg.voice.wakeword;

services.nginx.virtualHosts."${fqdn}" = {
http2 = true;

Expand Down
60 changes: 60 additions & 0 deletions test/services/home-assistant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,50 @@ let
# };
# };
# };

voice = {
shb.home-assistant.voice.text-to-speech = {
"fr" = {
enable = true;
voice = "fr-siwis-medium";
uri = "tcp://0.0.0.0:10200";
speaker = 0;
};
"en" = {
enable = true;
voice = "en_GB-alba-medium";
uri = "tcp://0.0.0.0:10201";
speaker = 0;
};
};
shb.home-assistant.voice.speech-to-text = {
"tiny-fr" = {
enable = true;
model = "base-int8";
language = "fr";
uri = "tcp://0.0.0.0:10300";
device = "cpu";
};
"tiny-en" = {
enable = true;
model = "base-int8";
language = "en";
uri = "tcp://0.0.0.0:10301";
device = "cpu";
};
};
shb.home-assistant.voice.wakeword = {
enable = true;
uri = "tcp://127.0.0.1:10400";
preloadModels = [
"alexa"
"hey_jarvis"
"hey_mycroft"
"hey_rhasspy"
"ok_nabu"
];
};
};
in
{
basic = pkgs.testers.runNixOSTest {
Expand Down Expand Up @@ -151,4 +195,20 @@ in
#
# testScript = commonTestScript.access;
# };

voice = pkgs.testers.runNixOSTest {
name = "homeassistant_ldap";

nodes.server = {
imports = [
base
basic
voice
];
};

nodes.client = {};

testScript = commonTestScript.access;
};
}

0 comments on commit a8b29b2

Please sign in to comment.