From a8b29b243cd2f3287e9bba38024e86c5a6c51e3b Mon Sep 17 00:00:00 2001 From: ibizaman Date: Mon, 29 Apr 2024 00:11:51 -0700 Subject: [PATCH] add voice option to home-assistant --- modules/services/home-assistant.nix | 40 +++++++++++++++++++ test/services/home-assistant.nix | 60 +++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/modules/services/home-assistant.nix b/modules/services/home-assistant.nix index c9b7949..834a158 100644 --- a/modules/services/home-assistant.nix +++ b/modules/services/home-assistant.nix @@ -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. @@ -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; diff --git a/test/services/home-assistant.nix b/test/services/home-assistant.nix index 296e164..5233d29 100644 --- a/test/services/home-assistant.nix +++ b/test/services/home-assistant.nix @@ -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 { @@ -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; + }; }