74 lines
2.2 KiB
Nix
74 lines
2.2 KiB
Nix
{ 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}";
|
|
};
|
|
};
|
|
|
|
})
|
|
];
|
|
}
|