nixpkgs/pkgs/tools/audio/tts/default.nix

112 lines
3.0 KiB
Nix
Raw Normal View History

2020-06-08 07:38:55 -07:00
{ lib
, python3Packages
, fetchFromGitHub
, python3
2021-04-16 00:33:04 -07:00
, fetchpatch
2020-06-08 07:38:55 -07:00
}:
2021-01-16 05:11:12 -08:00
# USAGE:
# $ tts-server --list_models
# # pick your favorite vocoder/tts model
# $ tts-server --model_name tts_models/en/ljspeech/glow-tts --vocoder_name vocoder_models/universal/libri-tts/fullband-melgan
2020-06-08 07:38:55 -07:00
#
2021-04-16 00:33:04 -07:00
# If you upgrade from an old version you may have to delete old models from ~/.local/share/tts
# Also note that your tts version might not support all available models so check:
2021-05-14 11:26:52 -07:00
# https://github.com/coqui-ai/TTS/releases/tag/v0.0.13
2021-04-16 00:33:04 -07:00
#
2020-06-08 07:38:55 -07:00
# For now, for deployment check the systemd unit in the pull request:
# https://github.com/NixOS/nixpkgs/pull/103851#issue-521121136
python3Packages.buildPythonApplication rec {
pname = "tts";
2021-05-14 11:26:52 -07:00
version = "0.0.13";
2020-06-08 07:38:55 -07:00
src = fetchFromGitHub {
owner = "coqui-ai";
2020-06-08 07:38:55 -07:00
repo = "TTS";
rev = "v${version}";
2021-05-14 11:26:52 -07:00
sha256 = "1sh7sjkh7ihbkqc7sl4hnzci0n7gv4s140dykpb1havaqyfhjn8l";
2020-06-08 07:38:55 -07:00
};
preBuild = ''
2021-05-14 11:26:52 -07:00
sed -i -e 's!librosa==[^"]*!librosa!' requirements.txt
sed -i -e 's!unidecode==[^"]*!unidecode!' requirements.txt
sed -i -e 's!numpy==[^"]*!numpy!' requirements.txt
sed -i -e 's!umap-learn==[^"]*!umap-learn!' requirements.txt
2020-06-08 07:38:55 -07:00
'';
2021-05-14 11:26:52 -07:00
nativeBuildInputs = with python3Packages; [
cython
];
2020-06-08 07:38:55 -07:00
propagatedBuildInputs = with python3Packages; [
flask
2020-06-08 07:38:55 -07:00
gdown
inflect
jieba
librosa
matplotlib
2021-05-14 11:26:52 -07:00
pandas
phonemizer
pypinyin
2020-06-08 07:38:55 -07:00
pysbd
pytorch
scipy
soundfile
tensorboardx
tqdm
umap-learn
unidecode
2020-06-08 07:38:55 -07:00
];
postInstall = ''
cp -r TTS/server/templates/ $out/${python3.sitePackages}/TTS/server
2021-01-16 05:11:12 -08:00
# cython modules are not installed for some reasons
(
cd TTS/tts/layers/glow_tts/monotonic_align
${python3Packages.python.interpreter} setup.py install --prefix=$out
)
2020-06-08 07:38:55 -07:00
'';
2021-05-14 11:26:52 -07:00
checkInputs = with python3Packages; [
pytestCheckHook
];
2020-06-08 07:38:55 -07:00
disabledTests = [
# RuntimeError: fft: ATen not compiled with MKL support
"test_torch_stft"
"test_stft_loss"
"test_multiscale_stft_loss"
2021-05-14 11:26:52 -07:00
# assert tensor(1.1904e-07, dtype=torch.float64) <= 0
2020-06-08 07:38:55 -07:00
"test_parametrized_gan_dataset"
2021-05-14 11:26:52 -07:00
# RuntimeError: expected scalar type Double but found Float
"test_speaker_embedding"
# Requires network acccess to download models
"test_synthesize"
2020-06-08 07:38:55 -07:00
];
2021-01-16 05:11:12 -08:00
preCheck = ''
# use the installed TTS in $PYTHONPATH instead of the one from source to also have cython modules.
mv TTS{,.old}
2021-05-14 11:26:52 -07:00
export PATH=$out/bin:$PATH
# numba tries to write to HOME directory
export HOME=$TMPDIR
2021-01-16 05:11:12 -08:00
'';
disabledTestPaths = [
2021-01-16 05:11:12 -08:00
# requires tensorflow
"tests/test_tacotron2_tf_model.py"
"tests/test_vocoder_tf_melgan_generator.py"
"tests/test_vocoder_tf_pqmf.py"
2021-01-16 05:11:12 -08:00
];
2020-06-08 07:38:55 -07:00
meta = with lib; {
homepage = "https://github.com/coqui-ai/TTS";
changelog = "https://github.com/coqui-ai/TTS/releases/tag/v${version}";
description = "Deep learning toolkit for Text-to-Speech, battle-tested in research and production";
2020-06-08 07:38:55 -07:00
license = licenses.mpl20;
maintainers = with maintainers; [ hexa mic92 ];
};
}