From 8bbe3617bfbe5486b0758352a2d4b15786552279 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Fri, 25 Aug 2023 11:33:25 +0200 Subject: [PATCH] made tts a component --- flake.lock | 66 ++++++++++----------- nixos/components/media/default.nix | 9 +-- nixos/components/media/tts.nix | 74 ++++++++++++++++++++++++ nixos/machines/chungus/configuration.nix | 7 +-- nixos/machines/cream/configuration.nix | 14 ++--- 5 files changed, 120 insertions(+), 50 deletions(-) create mode 100644 nixos/components/media/tts.nix diff --git a/flake.lock b/flake.lock index ca24909..4adcf82 100644 --- a/flake.lock +++ b/flake.lock @@ -47,11 +47,11 @@ ] }, "locked": { - "lastModified": 1690739034, - "narHash": "sha256-roW02IaiQ3gnEEDMCDWL5YyN+C4nBf/te6vfL7rG0jk=", + "lastModified": 1692199161, + "narHash": "sha256-GqKApvQ1JCf5DzH/Q+P4nwuHb6MaQGaWTu41lYzveF4=", "owner": "nix-community", "repo": "disko", - "rev": "4015740375676402a2ee6adebc3c30ea625b9a94", + "rev": "4eed2457b053c4bbad7d90d2b3a1d539c2c9009c", "type": "github" }, "original": { @@ -178,11 +178,11 @@ "emacs-overlay_2": { "flake": false, "locked": { - "lastModified": 1691318635, - "narHash": "sha256-gZYoohOyJqimEqm3xe/c9bSjDPipxFG1woRFduVWEvU=", + "lastModified": 1692934113, + "narHash": "sha256-DAQBNj9x6Fd90CxtuXovQJv7HRYC3EV2waHCNoy5RkY=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "4d4fe30a4cc9adef490fcc6c3bb7aaf08563c6d0", + "rev": "6ca342ac670b56ad15124314d71852276e892062", "type": "github" }, "original": { @@ -479,11 +479,11 @@ ] }, "locked": { - "lastModified": 1687871164, - "narHash": "sha256-bBFlPthuYX322xOlpJvkjUBz0C+MOBjZdDOOJJ+G2jU=", + "lastModified": 1692099905, + "narHash": "sha256-/pSusGhmIdSdAaywQRFA5dVbfdIzlWQTecM+E46+cJ0=", "owner": "nix-community", "repo": "home-manager", - "rev": "07c347bb50994691d7b0095f45ebd8838cf6bc38", + "rev": "2a6679aa9cc3872c29ba2a57fe1b71b3e3c5649f", "type": "github" }, "original": { @@ -543,11 +543,11 @@ }, "locked": { "dir": "nix", - "lastModified": 1691302749, - "narHash": "sha256-mak2sOtyT4LOcn6zPPMdaWH92tm9qC7Hta7+IaMmTGk=", + "lastModified": 1691843304, + "narHash": "sha256-aLAMpvbQPLkpjJDUWYTYRmEclAQTo+IVzqPQYOfmxfw=", "owner": "kmonad", "repo": "kmonad", - "rev": "ad69e1be793e61dce2d586481c0f6dda7d978c25", + "rev": "a05e93c62ca2c25cc81d76d9cf36880fe0bf183a", "type": "github" }, "original": { @@ -612,11 +612,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1691305349, - "narHash": "sha256-0Pig7jnmuRH3c5dOTVTOvTLwo2CRzYTyvJRQ82HWRSo=", + "lastModified": 1692373088, + "narHash": "sha256-EPgCecdc9I8aTdmDNoO1l7R72r2WPhZRcesV4nzxBj8=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "5426a95071d0b9782b3209b3995cde1f5689616e", + "rev": "7f1836531b126cfcf584e7d7d71bf8758bb58969", "type": "github" }, "original": { @@ -712,11 +712,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1690066826, - "narHash": "sha256-6L2qb+Zc0BFkh72OS9uuX637gniOjzU6qCDBpjB2LGY=", + "lastModified": 1692492726, + "narHash": "sha256-rld5qm2B4oRkDwcPD+yOSyTrZQdfCR6mzJGGkecjvTs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ce45b591975d070044ca24e3003c830d26fea1c8", + "rev": "5e63e8bbc46bc4fc22254da1edaf42fc7549c18a", "type": "github" }, "original": { @@ -728,11 +728,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1691186842, - "narHash": "sha256-wxBVCvZUwq+XS4N4t9NqsHV4E64cPVqQ2fdDISpjcw0=", + "lastModified": 1692734709, + "narHash": "sha256-SCFnyHCyYjwEmgUsHDDuU0TsbVMKeU1vwkR+r7uS2Rg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "18036c0be90f4e308ae3ebcab0e14aae0336fe42", + "rev": "b85ed9dcbf187b909ef7964774f8847d554fab3b", "type": "github" }, "original": { @@ -775,11 +775,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1691252436, - "narHash": "sha256-SKKPKYOnFcwqECehxoFBMLv29CZXC5qCDuETSuXd82g=", + "lastModified": 1692794066, + "narHash": "sha256-H0aG8r16dj0x/Wz6wQhQxc9V7AsObOiHPaKxQgH6Y08=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9607b9149c9d81fdf3dc4f3bcc278da146ffbd77", + "rev": "fc944919f743bb22379dddf18dcb72db6cff84aa", "type": "github" }, "original": { @@ -805,11 +805,11 @@ }, "nixpkgs_6": { "locked": { - "lastModified": 1690026219, - "narHash": "sha256-oOduRk/kzQxOBknZXTLSEYd7tk+GoKvr8wV6Ab+t4AU=", + "lastModified": 1692463654, + "narHash": "sha256-F8hZmsQINI+S6UROM4jyxAMbQLtzE44pI8Nk6NtMdao=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f465da166263bc0d4b39dfd4ca28b777c92d4b73", + "rev": "ca3c9ac9f4cdd4bea19f592b32bb59b74ab7d783", "type": "github" }, "original": { @@ -988,11 +988,11 @@ }, "retiolum": { "locked": { - "lastModified": 1690732808, - "narHash": "sha256-+1Y4wD7+fyFEWjWck6rxKYlDf6OB2zzFaPP71/zjdEU=", + "lastModified": 1691992809, + "narHash": "sha256-qUTsMDSV2L5t6Oj+L60n0KQKbvOhak3+d6++h9AZJPg=", "owner": "Mic92", "repo": "retiolum", - "rev": "e29c0b48310d4520a4beb9782e94949ae43ab1ae", + "rev": "6216c30551876303dac5373e92690a7f05fd0f6f", "type": "github" }, "original": { @@ -1117,11 +1117,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1690199016, - "narHash": "sha256-yTLL72q6aqGmzHq+C3rDp3rIjno7EJZkFLof6Ika7cE=", + "lastModified": 1692728678, + "narHash": "sha256-02MjG7Sb9k7eOi86CcC4GNWVOjT6gjmXFSqkRjZ8Xyk=", "owner": "Mic92", "repo": "sops-nix", - "rev": "c36df4fe4bf4bb87759b1891cab21e7a05219500", + "rev": "1b7b3a32d65dbcd69c217d7735fdf0a6b2184f45", "type": "github" }, "original": { diff --git a/nixos/components/media/default.nix b/nixos/components/media/default.nix index 5f997e5..5de2f67 100644 --- a/nixos/components/media/default.nix +++ b/nixos/components/media/default.nix @@ -5,9 +5,10 @@ with lib; enable = lib.mkEnableOption "Media configurations"; }; - imports = [ ./icecast.nix ]; + imports = [ + ./icecast.nix + ./tts.nix + ]; - config = mkIf config.components.media.enable { - # todo extract xorg stuff to prepare wayland - }; + config = mkIf config.components.media.enable { }; } diff --git a/nixos/components/media/tts.nix b/nixos/components/media/tts.nix new file mode 100644 index 0000000..9ab1f7b --- /dev/null +++ b/nixos/components/media/tts.nix @@ -0,0 +1,74 @@ +{ pkgs, config, lib, ... }: +with lib; +{ + + options.components.media.tts-server.enable = mkOption { + type = lib.types.bool; + #default = config.components.media.enable; + default = false; + }; + + options.components.media.tts-client.enable = mkOption { + type = lib.types.bool; + default = config.components.media.enable; + }; + + config = mkMerge [ + + (mkIf (config.components.media.tts-client.enable) { + environment.systemPackages = [ + pkgs.espeak-ng + pkgs.tts + (pkgs.writers.writeDashBin "tts-en" '' + ${pkgs.tts}/bin/tts --model_name "tts_models/en/ljspeech/vits" "$@" + '') + (pkgs.writers.writeDashBin "tts-de" '' + ${pkgs.tts}/bin/tts --model_name "tts_models/de/thorsten/vits" "$@" + '') + ]; + }) + + (mkIf (config.components.media.tts-server.enable) { + + # find models with ${pkgs.tts}/bin/tts --list_models + services.tts = { + servers = { + english = { + enable = true; + port = 5300; + #model = "tts_models/en/ljspeech/tacotron2-DDC"; + model = "tts_models/en/ljspeech/vits"; + }; + german = { + enable = true; + port = 5301; + #model = "tts_models/de/thorsten/tacotron2-DDC"; + model = "tts_models/de/thorsten/vits"; + }; + }; + }; + # fixes some issues + systemd.services.tts-german.serviceConfig.RestrictAddressFamilies = [ + "AF_UNIX" + ]; + systemd.services.tts-english.serviceConfig.RestrictAddressFamilies = [ + "AF_UNIX" + ]; + + services.nginx = { + recommendedProxySettings = true; + enable = true; + virtualHosts."tts.${config.networking.hostName}.private" = { + locations."/".proxyPass = "http://localhost:${toString config.services.tts.servers.english.port}"; + }; + virtualHosts."en.tts.${config.networking.hostName}.private" = { + locations."/".proxyPass = "http://localhost:${toString config.services.tts.servers.english.port}"; + }; + virtualHosts."de.tts.${config.networking.hostName}.private" = { + locations."/".proxyPass = "http://localhost:${toString config.services.tts.servers.german.port}"; + }; + }; + + }) + ]; +} diff --git a/nixos/machines/chungus/configuration.nix b/nixos/machines/chungus/configuration.nix index d77f142..af52f64 100644 --- a/nixos/machines/chungus/configuration.nix +++ b/nixos/machines/chungus/configuration.nix @@ -50,16 +50,15 @@ ./gitea.nix ./cache.nix - ./tts.nix ]; - components.terminal.enable = true; - components.mainUser.enable = true; components.gui.enable = false; - + components.mainUser.enable = true; + components.media.tts-server.enable = true; components.network.enable = true; components.network.wifi.enable = false; + components.terminal.enable = true; services.printing.enable = false; diff --git a/nixos/machines/cream/configuration.nix b/nixos/machines/cream/configuration.nix index 8623969..9b9b958 100644 --- a/nixos/machines/cream/configuration.nix +++ b/nixos/machines/cream/configuration.nix @@ -26,19 +26,15 @@ ./test.nix ]; - # stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-light-hard.yaml"; - - users.users.mainUser.extraGroups = [ "pipewire" ]; - - services.udev.extraRules = '' - KERNEL="ttyACM[0-9]*", MODE="0666" - ''; components.gui.enable = true; - components.terminal.enable = true; + components.mainUser.enable = true; + components.media.enable = true; components.network.enable = true; components.network.wifi.enable = true; - components.mainUser.enable = true; + components.terminal.enable = true; + + users.users.mainUser.extraGroups = [ "pipewire" ]; services.nginx.enable = true;