From 167f86417ecc8f0d605f2922dfbf1661f5412648 Mon Sep 17 00:00:00 2001 From: Agrin Hilmkil Date: Mon, 26 Apr 2021 20:34:01 +0200 Subject: [PATCH] Move dev, tf, notebook dependencies to extras --- .github/workflows/main.yml | 2 +- Makefile | 8 ++++++-- README.md | 9 ++++++++- TTS/speaker_encoder/utils/prepare_voxceleb.py | 13 ++++++------- requirements.dev.txt | 5 +++++ requirements.notebooks.txt | 2 ++ requirements.tf.txt | 1 + requirements.txt | 11 +---------- setup.py | 14 ++++++++++++++ 9 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 requirements.dev.txt create mode 100644 requirements.notebooks.txt create mode 100644 requirements.tf.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e874424..50295217 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,7 +43,7 @@ jobs: run: python3 -m pip install --upgrade pip - name: Install TTS run: | - python3 -m pip install . + python3 -m pip install .[all] python3 setup.py egg_info - name: Lint check run: | diff --git a/Makefile b/Makefile index baecd6f5..f3cf3d54 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .DEFAULT_GOAL := help -.PHONY: test deps style lint install help +.PHONY: test system-deps dev-deps deps style lint install help help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @@ -10,6 +10,10 @@ system-deps: ## install linux system deps sudo apt-get install -y espeak-ng sudo apt-get install -y libsndfile1-dev +dev-deps: ## install development deps + pip install -r requirements.dev.txt + pip install -r requirements.tf.txt + deps: ## install 🐸 requirements. pip install -r requirements.txt @@ -25,4 +29,4 @@ lint: ## run pylint linter. pylint ${target_dirs} install: ## install 🐸 TTS for development. - pip install -e . + pip install -e .[all] diff --git a/README.md b/README.md index 5df30283..30291eba 100644 --- a/README.md +++ b/README.md @@ -110,11 +110,17 @@ If you are only interested in [synthesizing speech](https://github.com/coqui-ai/ pip install TTS ``` +By default this only installs the requirements for PyTorch. To install the tensorflow dependencies as well, use the `tf` extra. + +```bash +pip install TTS[tf] +``` + If you plan to code or train models, clone 🐸TTS and install it locally. ```bash git clone https://github.com/coqui-ai/TTS -pip install -e . +pip install -e .[all,dev,notebooks,tf] # Select the relevant extras ``` We use ```espeak-ng``` to convert graphemes to phonemes. You might need to install separately. @@ -127,6 +133,7 @@ If you are on Ubuntu (Debian), you can also run following commands for installat ```bash $ make system-deps # intended to be used on Ubuntu (Debian). Let us know if you have a diffent OS. +$ make dev-deps # Dependencies only required for development $ make install ``` diff --git a/TTS/speaker_encoder/utils/prepare_voxceleb.py b/TTS/speaker_encoder/utils/prepare_voxceleb.py index 1901a21c..b444d564 100644 --- a/TTS/speaker_encoder/utils/prepare_voxceleb.py +++ b/TTS/speaker_encoder/utils/prepare_voxceleb.py @@ -25,12 +25,11 @@ import subprocess import sys import zipfile +import fsspec import pandas import soundfile as sf -import tensorflow as tf from absl import logging -gfile = tf.compat.v1.gfile SUBSETS = { "vox1_dev_wav": [ @@ -73,8 +72,7 @@ def download_and_extract(directory, subset, urls): subset: subset name of the corpus. urls: the list of urls to download the data file. """ - if not gfile.Exists(directory): - gfile.MakeDirs(directory) + fsspec.get_mapper(directory).fs.makedirs(directory, exist_ok=True) try: for url in urls: @@ -107,7 +105,7 @@ def download_and_extract(directory, subset, urls): extract_path_ori = os.path.join(directory, zfile.infolist()[0].filename) subprocess.call("mv %s %s" % (extract_path_ori, extract_path), shell=True) finally: - # gfile.Remove(zip_filepath) + # fsspec.get_mapper(directory).fs.rm_file(zip_filepath) pass @@ -160,7 +158,8 @@ def convert_audio_and_make_label(input_dir, subset, output_dir, output_file): files = [] # Convert all AAC file into WAV format. At the same time, generate the csv - for root, _, filenames in gfile.Walk(source_dir): + fs = fsspec.get_mapper(source_dir).fs + for root, _, filenames in fs.walk(source_dir): for filename in filenames: name, ext = os.path.splitext(filename) if ext.lower() == ".wav": @@ -172,7 +171,7 @@ def convert_audio_and_make_label(input_dir, subset, output_dir, output_file): # Convert AAC to WAV. aac_file = os.path.join(root, filename) wav_file = aac_file + ".wav" - if not gfile.Exists(wav_file): + if not fs.exists(wav_file): if not decode_aac_with_ffmpeg(aac_file, wav_file): raise RuntimeError("Audio decoding failed.") else: diff --git a/requirements.dev.txt b/requirements.dev.txt new file mode 100644 index 00000000..22e3812b --- /dev/null +++ b/requirements.dev.txt @@ -0,0 +1,5 @@ +nose +coverage +black +isort +pylint==2.7.4 diff --git a/requirements.notebooks.txt b/requirements.notebooks.txt new file mode 100644 index 00000000..153e29f5 --- /dev/null +++ b/requirements.notebooks.txt @@ -0,0 +1,2 @@ +bokeh==1.4.0 +numba==0.48 diff --git a/requirements.tf.txt b/requirements.tf.txt new file mode 100644 index 00000000..60f6e6c9 --- /dev/null +++ b/requirements.tf.txt @@ -0,0 +1 @@ +tensorflow==2.3.1 diff --git a/requirements.txt b/requirements.txt index eedf7d61..a8c92e87 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,6 @@ torch>=1.7 -tensorflow==2.3.1 numpy==1.18.5 scipy>=0.19.0 -numba==0.48 librosa==0.7.2 phonemizer>=2.2.0 unidecode==0.4.20 @@ -10,20 +8,13 @@ pypinyin jieba tensorboardX matplotlib -Pillow flask tqdm inflect -bokeh==1.4.0 pysbd soundfile gdown umap-learn==0.4.6 cython pyyaml -# quality and style -nose -coverage -black -isort -pylint==2.7.4 \ No newline at end of file +fsspec>=0.8.0 diff --git a/setup.py b/setup.py index 338c546a..21d1eb2e 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,14 @@ def pip_install(package_name): requirements = open(os.path.join(cwd, 'requirements.txt'), 'r').readlines() +with open(os.path.join(cwd, 'requirements.notebooks.txt'), 'r') as f: + requirements_notebooks = f.readlines() +with open(os.path.join(cwd, 'requirements.dev.txt'), 'r') as f: + requirements_dev = f.readlines() +with open(os.path.join(cwd, 'requirements.tf.txt'), 'r') as f: + requirements_tf = f.readlines() +requirements_all = requirements_dev + requirements_notebooks + requirements_tf + with open('README.md', "r", encoding="utf-8") as readme_file: README = readme_file.read() @@ -82,6 +90,12 @@ setup( # 'build_ext': build_ext }, install_requires=requirements, + extras_require={ + "all": requirements_all, + "dev": requirements_dev, + "notebooks": requirements_notebooks, + "tf": requirements_tf, + }, python_requires='>=3.6.0, <3.9', entry_points={ 'console_scripts': [