From a7455e691175a1c70f94bcaa1ba94b11507dfa77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 9 Nov 2020 11:52:08 +0100 Subject: [PATCH 1/2] python3.pkgs.pysbd: init at 0.3.3 --- .../python-modules/pysbd/default.nix | 31 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 pkgs/development/python-modules/pysbd/default.nix diff --git a/pkgs/development/python-modules/pysbd/default.nix b/pkgs/development/python-modules/pysbd/default.nix new file mode 100644 index 000000000000..e1e0578c83b8 --- /dev/null +++ b/pkgs/development/python-modules/pysbd/default.nix @@ -0,0 +1,31 @@ +{ lib +, buildPythonPackage +, fetchPypi +, pythonOlder +, tqdm +, spacy +}: + +buildPythonPackage rec { + pname = "pysbd"; + version = "0.3.3"; + disabled = pythonOlder "3.5"; + + src = fetchPypi { + inherit pname version; + sha256 = "56ab48a28a8470f0042a4cb7c9da8a6dde8621ecf87a86d75f201cbf1837e77f"; + }; + + checkInputs = [ tqdm spacy ]; + + doCheck = false; # requires pyconll and blingfire + + pythonImportsCheck = [ "pysbd" ]; + + meta = with lib; { + description = "Pysbd (Python Sentence Boundary Disambiguation) is a rule-based sentence boundary detection that works out-of-the-box across many languages"; + homepage = "https://github.com/nipunsadvilkar/pySBD"; + license = licenses.mit; + maintainers = [ maintainers.mic92 ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 51ae93b0eb18..ec3145a630ca 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4568,6 +4568,8 @@ in { pkuseg = callPackage ../development/python-modules/pkuseg { }; + pysbd = callPackage ../development/python-modules/pysbd { }; + python-csxcad = callPackage ../development/python-modules/python-csxcad { }; python-openems = callPackage ../development/python-modules/python-openems { }; From c84ad307e66e3b22a918921523ced5362efab1d7 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 8 Jun 2020 16:38:55 +0200 Subject: [PATCH 2/2] tts: init at unstable-2020-06-17 --- pkgs/tools/audio/tts/default.nix | 123 +++++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 125 insertions(+) create mode 100644 pkgs/tools/audio/tts/default.nix diff --git a/pkgs/tools/audio/tts/default.nix b/pkgs/tools/audio/tts/default.nix new file mode 100644 index 000000000000..770e898f2eec --- /dev/null +++ b/pkgs/tools/audio/tts/default.nix @@ -0,0 +1,123 @@ +{ lib +, python3Packages +, fetchFromGitHub +, fetchpatch +, python3 +}: + +# +# Tested in the following setup: +# +# TTS model: +# Tacotron2 DDC +# https://drive.google.com/drive/folders/1Y_0PcB7W6apQChXtbt6v3fAiNwVf4ER5 +# Vocoder model: +# Multi-Band MelGAN +# https://drive.google.com/drive/folders/1XeRT0q4zm5gjERJqwmX5w84pMrD00cKD +# +# Arrange /tmp/tts like this: +# scale_stats.npy +# tts +# tts/checkpoint_130000.pth.tar +# tts/checkpoint_130000_tf.pkl +# tts/checkpoint_130000_tf_2.3rc0.tflite +# tts/config.json +# tts/scale_stats.npy +# vocoder +# vocoder/checkpoint_1450000.pth.tar +# vocoder/checkpoint_2750000_tf.pkl +# vocoder/checkpoint_2750000_tf_v2.3rc.tflite +# vocoder/config.json +# vocoder/scale_stats.npy +# +# Start like this: +# cd /tmp/tts +# tts-server \ +# --vocoder_config ./tts/vocoder/config.json \ +# --vocoder_checkpoint ./tts/vocoder/checkpoint_1450000.pth.tar \ +# --tts_config ./tts/config.json \ +# --tts_checkpoint ./tts/checkpoint_130000.pth.tar +# +# 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"; + # until https://github.com/mozilla/TTS/issues/424 is resolved + # we treat released models as released versions: + # https://github.com/mozilla/TTS/wiki/Released-Models + version = "unstable-2020-06-17"; + + src = fetchFromGitHub { + owner = "mozilla"; + repo = "TTS"; + rev = "72a6ac54c8cfaa407fc64b660248c6a788bdd381"; + sha256 = "1wvs264if9n5xzwi7ryxvwj1j513szp6sfj6n587xk1fphi0921f"; + }; + + patches = [ + (fetchpatch { + url = "https://github.com/mozilla/TTS/commit/36fee428b9f3f4ec1914b090a2ec9d785314d9aa.patch"; + sha256 = "sha256-pP0NxiyrsvQ0A7GEleTdT87XO08o7WxPEpb6Bmj66dc="; + }) + ]; + + preBuild = '' + # numba jit tries to write to its cache directory + export HOME=$TMPDIR + sed -i -e 's!tensorflow==.*!tensorflow!' requirements.txt + sed -i -e 's!librosa==[^"]*!librosa!' requirements.txt setup.py + sed -i -e 's!unidecode==[^"]*!unidecode!' requirements.txt setup.py + sed -i -e 's!bokeh==[^"]*!bokeh!' requirements.txt setup.py + sed -i -e 's!numba==[^"]*!numba!' requirements.txt setup.py + # Not required for building/installation but for their development/ci workflow + sed -i -e '/pylint/d' requirements.txt setup.py + sed -i -e '/cardboardlint/d' requirements.txt setup.py + ''; + + + propagatedBuildInputs = with python3Packages; [ + matplotlib + scipy + pytorch + flask + attrdict + bokeh + soundfile + tqdm + librosa + unidecode + phonemizer + tensorboardx + fuzzywuzzy + tensorflow_2 + inflect + gdown + pysbd + ]; + + postInstall = '' + cp -r TTS/server/templates/ $out/${python3.sitePackages}/TTS/server + ''; + + checkInputs = with python3Packages; [ pytestCheckHook ]; + + disabledTests = [ + # RuntimeError: fft: ATen not compiled with MKL support + "test_torch_stft" + "test_stft_loss" + "test_multiscale_stft_loss" + # AssertionErrors that I feel incapable of debugging + "test_phoneme_to_sequence" + "test_text2phone" + "test_parametrized_gan_dataset" + ]; + + meta = with lib; { + homepage = "https://github.com/mozilla/TTS"; + description = "Deep learning for Text to Speech"; + license = licenses.mpl20; + maintainers = with maintainers; [ hexa mic92 ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 115b23032375..0281bc4b7b53 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25840,6 +25840,8 @@ julia_15 = callPackage ../development/compilers/julia/1.5.nix { tremulous = callPackage ../games/tremulous { }; + tts = callPackage ../tools/audio/tts { }; + tuxpaint = callPackage ../games/tuxpaint { }; tuxtype = callPackage ../games/tuxtype { };