anchor.diff:      tqdm
       librosa
       unidecode
  +    umap-learn
       phonemizer
       tensorboardx
       fuzzywuzzy
  -    tensorflow_2
       inflect
       gdown
       pysbd
  +    pyworld
     ];
   
     postInstall = ''
       cp -r TTS/server/templates/ $out/${python3.sitePackages}/TTS/server
  +    # cython modules are not installed for some reasons
  +    (
  +      cd TTS/tts/layers/glow_tts/monotonic_align
  +      ${python3Packages.python.interpreter} setup.py install --prefix=$out
  +    )
     '';
   
     checkInputs = with python3Packages; [ pytestCheckHook ];
  
positive.code:   # 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
  
negative.code: { lib
  , python3Packages
  , fetchFromGitHub
  , python3
  }:
  
  # 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
  #
  # For now, for deployment check the systemd unit in the pull request:
  #   https://github.com/NixOS/nixpkgs/pull/103851#issue-521121136
  