From 617605c8fe6c57e67ad2cda29bd05c2462c1d59c Mon Sep 17 00:00:00 2001 From: chenfeiyu Date: Thu, 21 Nov 2019 23:02:32 +0800 Subject: [PATCH] place parakeet into Parakeet/parakeet, and add tests --- .gitignore | 129 ++++++++++++++++++ .gitingore | 2 - {data => parakeet}/__init__.py | 0 parakeet/data/.vscode/settings.json | 3 + {hparam_tf => parakeet/data}/__init__.py | 0 data/collate.py => parakeet/data/batch.py | 52 +++++-- .../data/datacargo.py | 23 ++-- {data => parakeet/data}/dataset.py | 14 +- {data => parakeet/data}/ljspeech.py | 69 ++++------ {data => parakeet/data}/sampler.py | 0 {deepvoice3 => parakeet/deepvoice3}/README.md | 0 .../deepvoice3}/README_cn.md | 0 {deepvoice3 => parakeet/deepvoice3}/_ce.py | 0 .../_images/model_architecture.png | Bin {deepvoice3 => parakeet/deepvoice3}/audio.py | 0 .../deepvoice3}/builder.py | 0 .../deepvoice3}/compute_timestamp_ratio.py | 0 {deepvoice3 => parakeet/deepvoice3}/data.py | 0 .../deepvoice3}/deepvoice3.py | 0 .../deepvoice3}/dry_run.py | 0 .../deepvoice3}/eval_model.py | 0 .../deepvoice3}/hparams.py | 0 .../deepvoice3}/ljspeech.py | 0 .../deepvoice3}/preprocess.py | 0 .../presets/deepvoice3_ljspeech.json | 0 .../deepvoice3}/synthesis.py | 0 {deepvoice3 => parakeet/deepvoice3}/train.py | 0 {deepvoice3 => parakeet/deepvoice3}/train.sh | 0 .../deepvoice3}/train_model.py | 0 {g2p => parakeet/g2p}/__init__.py | 8 +- {g2p => parakeet/g2p}/en/__init__.py | 7 +- {g2p => parakeet/g2p}/es/__init__.py | 6 +- {g2p => parakeet/g2p}/jp/__init__.py | 0 {g2p => parakeet/g2p}/ko/__init__.py | 0 {g2p => parakeet/g2p}/text/__init__.py | 4 +- {g2p => parakeet/g2p}/text/cleaners.py | 0 {g2p => parakeet/g2p}/text/cmudict.py | 0 {g2p => parakeet/g2p}/text/numbers.py | 0 {g2p => parakeet/g2p}/text/symbols.py | 0 parakeet/hparam_tf/__init__.py | 0 {hparam_tf => parakeet/hparam_tf}/hparam.py | 0 {hparam_tf => parakeet/hparam_tf}/readme.md | 0 tests/test_ljspeech.py | 10 ++ 43 files changed, 233 insertions(+), 94 deletions(-) create mode 100644 .gitignore delete mode 100644 .gitingore rename {data => parakeet}/__init__.py (100%) create mode 100644 parakeet/data/.vscode/settings.json rename {hparam_tf => parakeet/data}/__init__.py (100%) rename data/collate.py => parakeet/data/batch.py (57%) rename data/dataloader.py => parakeet/data/datacargo.py (75%) rename {data => parakeet/data}/dataset.py (52%) rename {data => parakeet/data}/ljspeech.py (58%) rename {data => parakeet/data}/sampler.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/README.md (100%) rename {deepvoice3 => parakeet/deepvoice3}/README_cn.md (100%) rename {deepvoice3 => parakeet/deepvoice3}/_ce.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/_images/model_architecture.png (100%) rename {deepvoice3 => parakeet/deepvoice3}/audio.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/builder.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/compute_timestamp_ratio.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/data.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/deepvoice3.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/dry_run.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/eval_model.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/hparams.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/ljspeech.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/preprocess.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/presets/deepvoice3_ljspeech.json (100%) rename {deepvoice3 => parakeet/deepvoice3}/synthesis.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/train.py (100%) rename {deepvoice3 => parakeet/deepvoice3}/train.sh (100%) rename {deepvoice3 => parakeet/deepvoice3}/train_model.py (100%) rename {g2p => parakeet/g2p}/__init__.py (86%) rename {g2p => parakeet/g2p}/en/__init__.py (82%) rename {g2p => parakeet/g2p}/es/__init__.py (61%) rename {g2p => parakeet/g2p}/jp/__init__.py (100%) rename {g2p => parakeet/g2p}/ko/__init__.py (100%) rename {g2p => parakeet/g2p}/text/__init__.py (97%) rename {g2p => parakeet/g2p}/text/cleaners.py (100%) rename {g2p => parakeet/g2p}/text/cmudict.py (100%) rename {g2p => parakeet/g2p}/text/numbers.py (100%) rename {g2p => parakeet/g2p}/text/symbols.py (100%) create mode 100644 parakeet/hparam_tf/__init__.py rename {hparam_tf => parakeet/hparam_tf}/hparam.py (100%) rename {hparam_tf => parakeet/hparam_tf}/readme.md (100%) create mode 100644 tests/test_ljspeech.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9fe17bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,129 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ \ No newline at end of file diff --git a/.gitingore b/.gitingore deleted file mode 100644 index 6dcca85..0000000 --- a/.gitingore +++ /dev/null @@ -1,2 +0,0 @@ -*.pyc -*.tar.* diff --git a/data/__init__.py b/parakeet/__init__.py similarity index 100% rename from data/__init__.py rename to parakeet/__init__.py diff --git a/parakeet/data/.vscode/settings.json b/parakeet/data/.vscode/settings.json new file mode 100644 index 0000000..77b9721 --- /dev/null +++ b/parakeet/data/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/Users/chenfeiyu/miniconda3/envs/paddle/bin/python" +} \ No newline at end of file diff --git a/hparam_tf/__init__.py b/parakeet/data/__init__.py similarity index 100% rename from hparam_tf/__init__.py rename to parakeet/data/__init__.py diff --git a/data/collate.py b/parakeet/data/batch.py similarity index 57% rename from data/collate.py rename to parakeet/data/batch.py index bdd582c..9303b46 100644 --- a/data/collate.py +++ b/parakeet/data/batch.py @@ -3,7 +3,17 @@ functions to make batch for arrays which satisfy some conditions. """ import numpy as np -def text_collate(minibatch): +class TextIDBatcher(object): + """A wrapper class for a function to build a functor, which holds the configs to pass to the function.""" + def __init__(self, pad_id=0, dtype=np.int64): + self.pad_id = pad_id + self.dtype = dtype + + def __call__(self, minibatch): + out = batch_text_id(minibatch, pad_id=self.pad_id, dtype=self.dtype) + return out + +def batch_text_id(minibatch, pad_id=0, dtype=np.int64): """ minibatch: List[Example] Example: ndarray, shape(T,), dtype: int64 @@ -17,15 +27,25 @@ def text_collate(minibatch): batch = [] for example in minibatch: pad_len = max_len - example.shape[0] - batch.append(np.pad(example, [(0, pad_len)], mode='constant', constant_values=0)) + batch.append(np.pad(example, [(0, pad_len)], mode='constant', constant_values=pad_id)) - return np.array(batch, dtype=np.int64) + return np.array(batch, dtype=dtype) -def wav_collate(minibatch): +class WavBatcher(object): + def __init__(self, pad_value=0., dtype=np.float32): + self.pad_value = pad_value + self.dtype = dtype + + def __call__(self, minibatch): + out = batch_wav(minibatch, pad_value=self.pad_value, dtype=self.dtype) + return out + +def batch_wav(minibatch, pad_value=0., dtype=np.float32): """ minibatch: List[Example] Example: ndarray, shape(C, T) for multi-channel wav, shape(T,) for mono-channel wav, dtype: float32 """ + # detect data format, maybe better to specify it in __init__ peek_example = minibatch[0] if len(peek_example.shape) == 1: mono_channel = True @@ -39,13 +59,23 @@ def wav_collate(minibatch): for example in minibatch: pad_len = max_len - example.shape[-1] if mono_channel: - batch.append(np.pad(example, [(0, pad_len)], mode='constant', constant_values=0.)) + batch.append(np.pad(example, [(0, pad_len)], mode='constant', constant_values=pad_value)) else: - batch.append(np.pad(example, [(0, 0), (0, pad_len)], mode='constant', constant_values=0.)) # what about PCM, no + batch.append(np.pad(example, [(0, 0), (0, pad_len)], mode='constant', constant_values=pad_value)) # what about PCM, no - return np.array(batch, dtype=np.float32) + return np.array(batch, dtype=dtype) -def spec_collate(minibatch): + +class SpecBatcher(object): + def __init__(self, pad_value=0., dtype=np.float32): + self.pad_value = pad_value + self.dtype = dtype + + def __call__(self, minibatch): + out = batch_spec(minibatch, pad_value=self.pad_value, dtype=self.dtype) + return out + +def batch_spec(minibatch, pad_value=0., dtype=np.float32): """ minibatch: List[Example] Example: ndarray, shape(C, F, T) for multi-channel spectrogram, shape(F, T) for mono-channel spectrogram, dtype: float32 @@ -64,8 +94,8 @@ def spec_collate(minibatch): for example in minibatch: pad_len = max_len - example.shape[-1] if mono_channel: - batch.append(np.pad(example, [(0, 0), (0, pad_len)], mode='constant', constant_values=0.)) + batch.append(np.pad(example, [(0, 0), (0, pad_len)], mode='constant', constant_values=pad_value)) else: - batch.append(np.pad(example, [(0, 0), (0, 0), (0, pad_len)], mode='constant', constant_values=0.)) # what about PCM, no + batch.append(np.pad(example, [(0, 0), (0, 0), (0, pad_len)], mode='constant', constant_values=pad_value)) # what about PCM, no - return np.array(batch, dtype=np.float32) \ No newline at end of file + return np.array(batch, dtype=dtype) \ No newline at end of file diff --git a/data/dataloader.py b/parakeet/data/datacargo.py similarity index 75% rename from data/dataloader.py rename to parakeet/data/datacargo.py index 231322c..07f9d37 100644 --- a/data/dataloader.py +++ b/parakeet/data/datacargo.py @@ -1,10 +1,9 @@ -from sampler import SequentialSampler, RandomSampler, BatchSampler +from .sampler import SequentialSampler, RandomSampler, BatchSampler -class DataLoader(object): - def __init__(self, dataset, batch_size=1, collate_fn = lambda x: x, - sampler=None, shuffle=False, batch_sampler=None, drop_last=False): +class DataCargo(object): + def __init__(self, dataset, batch_size=1, sampler=None, + shuffle=False, batch_sampler=None, drop_last=False): self.dataset = dataset - self.collate_fn = collate_fn if batch_sampler is not None: # auto_collation with custom batch_sampler @@ -14,20 +13,14 @@ class DataLoader(object): 'drop_last') batch_size = None drop_last = False + shuffle = False elif batch_size is None: - # no auto_collation - if shuffle or drop_last: - raise ValueError('batch_size=None option disables auto-batching ' - 'and is mutually exclusive with ' - 'shuffle, and drop_last') - - if sampler is None: # give default samplers + raise ValueError('batch sampler is none. then batch size must not be none.') + elif sampler is None: if shuffle: sampler = RandomSampler(dataset) else: sampler = SequentialSampler(dataset) - - if batch_size is not None and batch_sampler is None: # auto_collation without custom batch_sampler batch_sampler = BatchSampler(sampler, batch_size, drop_last) @@ -73,7 +66,7 @@ class DataIterator(object): def __next__(self): index = self._next_index() # may raise StopIteration, TODO(chenfeiyu): use dynamic batch size minibatch = [self._dataset[i] for i in index] # we can abstract it, too to use dynamic batch size - minibatch = self.loader.collate_fn(minibatch) # list[Example] -> Batch + minibatch = self._dataset._batch_examples(minibatch) # list[Example] -> Batch return minibatch def _next_index(self): diff --git a/data/dataset.py b/parakeet/data/dataset.py similarity index 52% rename from data/dataset.py rename to parakeet/data/dataset.py index 2b3ecd4..cfec912 100644 --- a/data/dataset.py +++ b/parakeet/data/dataset.py @@ -1,16 +1,16 @@ class Dataset(object): - def __init__(self, lazy=True, stream=False): - # note that lazy and stream means two different things in our glossary - # lazy means to place preprocessing in __getitem__ - # stram means the data source is itself a stream - self.lazy = lazy - self.stream = stream + def __init__(self): + pass def _load_metadata(self): raise NotImplementedError def _get_example(self): - """return a Record""" + """return a Record (or Example, Instance according to your glossary)""" + raise NotImplementedError + + def _batch_examples(self, minibatch): + """get a list of examples, return a batch, whose structure is the same as an example""" raise NotImplementedError def _prepare_metadata(self): diff --git a/data/ljspeech.py b/parakeet/data/ljspeech.py similarity index 58% rename from data/ljspeech.py rename to parakeet/data/ljspeech.py index b2eb56e..4ee51de 100644 --- a/data/ljspeech.py +++ b/parakeet/data/ljspeech.py @@ -2,23 +2,19 @@ from pathlib import Path import numpy as np import pandas as pd import librosa -import g2p +from .. import g2p -from sampler import SequentialSampler, RandomSampler, BatchSampler -from dataset import Dataset -from dataloader import DataLoader +from .sampler import SequentialSampler, RandomSampler, BatchSampler +from .dataset import Dataset +from .datacargo import DataCargo +from .batch import TextIDBatcher, SpecBatcher -from collate import text_collate, spec_collate -LJSPEECH_ROOT = Path("/Users/chenfeiyu/projects/LJSpeech-1.1") class LJSpeech(Dataset): - def __init__(self, root=LJSPEECH_ROOT, lazy=True, stream=False): - super(LJSpeech, self).__init__(lazy, stream) + def __init__(self, root): + super(LJSpeech, self).__init__() self.root = root self.metadata = self._prepare_metadata() # we can do this just for luck - - if self.stream: - self.examples_generator = self._read() def _prepare_metadata(self): # if pure-stream case, each _prepare_metadata returns a generator @@ -26,11 +22,6 @@ class LJSpeech(Dataset): metadata = pd.read_csv(csv_path, sep="|", header=None, quoting=3, names=["fname", "raw_text", "normalized_text"]) return metadata - - def _read(self): - for _, metadatum in self.metadata.iterrows(): - example = self._get_example(metadatum) - yield example def _get_example(self, metadatum): """All the code for generating an Example from a metadatum. If you want a @@ -62,44 +53,30 @@ class LJSpeech(Dataset): phonemes = np.array(g2p.en.text_to_sequence(normalized_text), dtype=np.int64) return (mag, mel, phonemes) # maybe we need to implement it as a map in the future + def _batch_examples(self, minibatch): + mag_batch = [] + mel_batch = [] + phoneme_batch = [] + for example in minibatch: + mag, mel, phoneme = example + mag_batch.append(mag) + mel_batch.append(mel) + phoneme_batch.append(phoneme) + mag_batch = SpecBatcher(pad_value=0.)(mag_batch) + mel_batch = SpecBatcher(pad_value=0.)(mel_batch) + phoneme_batch = TextIDBatcher(pad_id=0)(phoneme_batch) + return (mag_batch, mel_batch, phoneme_batch) + def __getitem__(self, index): - if self.stream: - raise ValueError("__getitem__ is invalid in stream mode") metadatum = self.metadata.iloc[index] example = self._get_example(metadatum) return example def __iter__(self): - if self.stream: - for example in self.examples_generator: - yield example - else: - for i in range(len(self)): - yield self[i] + for i in range(len(self)): + yield self[i] def __len__(self): - if self.stream: - raise ValueError("__len__ is invalid in stream mode") return len(self.metadata) -def fn(minibatch): - mag_batch = [] - mel_batch = [] - phoneme_batch = [] - for example in minibatch: - mag, mel, phoneme = example - mag_batch.append(mag) - mel_batch.append(mel) - phoneme_batch.append(phoneme) - mag_batch = spec_collate(mag_batch) - mel_batch = spec_collate(mel_batch) - phoneme_batch = text_collate(phoneme_batch) - return (mag_batch, mel_batch, phoneme_batch) - -if __name__ == "__main__": - ljspeech = LJSpeech(LJSPEECH_ROOT) - ljspeech_loader = DataLoader(ljspeech, batch_size=16, shuffle=True, collate_fn=fn) - for i, batch in enumerate(ljspeech_loader): - print(i) - diff --git a/data/sampler.py b/parakeet/data/sampler.py similarity index 100% rename from data/sampler.py rename to parakeet/data/sampler.py diff --git a/deepvoice3/README.md b/parakeet/deepvoice3/README.md similarity index 100% rename from deepvoice3/README.md rename to parakeet/deepvoice3/README.md diff --git a/deepvoice3/README_cn.md b/parakeet/deepvoice3/README_cn.md similarity index 100% rename from deepvoice3/README_cn.md rename to parakeet/deepvoice3/README_cn.md diff --git a/deepvoice3/_ce.py b/parakeet/deepvoice3/_ce.py similarity index 100% rename from deepvoice3/_ce.py rename to parakeet/deepvoice3/_ce.py diff --git a/deepvoice3/_images/model_architecture.png b/parakeet/deepvoice3/_images/model_architecture.png similarity index 100% rename from deepvoice3/_images/model_architecture.png rename to parakeet/deepvoice3/_images/model_architecture.png diff --git a/deepvoice3/audio.py b/parakeet/deepvoice3/audio.py similarity index 100% rename from deepvoice3/audio.py rename to parakeet/deepvoice3/audio.py diff --git a/deepvoice3/builder.py b/parakeet/deepvoice3/builder.py similarity index 100% rename from deepvoice3/builder.py rename to parakeet/deepvoice3/builder.py diff --git a/deepvoice3/compute_timestamp_ratio.py b/parakeet/deepvoice3/compute_timestamp_ratio.py similarity index 100% rename from deepvoice3/compute_timestamp_ratio.py rename to parakeet/deepvoice3/compute_timestamp_ratio.py diff --git a/deepvoice3/data.py b/parakeet/deepvoice3/data.py similarity index 100% rename from deepvoice3/data.py rename to parakeet/deepvoice3/data.py diff --git a/deepvoice3/deepvoice3.py b/parakeet/deepvoice3/deepvoice3.py similarity index 100% rename from deepvoice3/deepvoice3.py rename to parakeet/deepvoice3/deepvoice3.py diff --git a/deepvoice3/dry_run.py b/parakeet/deepvoice3/dry_run.py similarity index 100% rename from deepvoice3/dry_run.py rename to parakeet/deepvoice3/dry_run.py diff --git a/deepvoice3/eval_model.py b/parakeet/deepvoice3/eval_model.py similarity index 100% rename from deepvoice3/eval_model.py rename to parakeet/deepvoice3/eval_model.py diff --git a/deepvoice3/hparams.py b/parakeet/deepvoice3/hparams.py similarity index 100% rename from deepvoice3/hparams.py rename to parakeet/deepvoice3/hparams.py diff --git a/deepvoice3/ljspeech.py b/parakeet/deepvoice3/ljspeech.py similarity index 100% rename from deepvoice3/ljspeech.py rename to parakeet/deepvoice3/ljspeech.py diff --git a/deepvoice3/preprocess.py b/parakeet/deepvoice3/preprocess.py similarity index 100% rename from deepvoice3/preprocess.py rename to parakeet/deepvoice3/preprocess.py diff --git a/deepvoice3/presets/deepvoice3_ljspeech.json b/parakeet/deepvoice3/presets/deepvoice3_ljspeech.json similarity index 100% rename from deepvoice3/presets/deepvoice3_ljspeech.json rename to parakeet/deepvoice3/presets/deepvoice3_ljspeech.json diff --git a/deepvoice3/synthesis.py b/parakeet/deepvoice3/synthesis.py similarity index 100% rename from deepvoice3/synthesis.py rename to parakeet/deepvoice3/synthesis.py diff --git a/deepvoice3/train.py b/parakeet/deepvoice3/train.py similarity index 100% rename from deepvoice3/train.py rename to parakeet/deepvoice3/train.py diff --git a/deepvoice3/train.sh b/parakeet/deepvoice3/train.sh similarity index 100% rename from deepvoice3/train.sh rename to parakeet/deepvoice3/train.sh diff --git a/deepvoice3/train_model.py b/parakeet/deepvoice3/train_model.py similarity index 100% rename from deepvoice3/train_model.py rename to parakeet/deepvoice3/train_model.py diff --git a/g2p/__init__.py b/parakeet/g2p/__init__.py similarity index 86% rename from g2p/__init__.py rename to parakeet/g2p/__init__.py index 2d513be..2b88bdc 100644 --- a/g2p/__init__.py +++ b/parakeet/g2p/__init__.py @@ -12,22 +12,22 @@ and the property: - n_vocab """ -from g2p import en +from . import en # optinoal Japanese frontend try: - from g2p import jp + from . import jp except ImportError: jp = None try: - from g2p import ko + from . import ko except ImportError: ko = None # if you are going to use the frontend, you need to modify _characters in symbol.py: # _characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!\'(),-.:;? ' + '¡¿ñáéíóúÁÉÍÓÚÑ' try: - from g2p import es + from . import es except ImportError: es = None diff --git a/g2p/en/__init__.py b/parakeet/g2p/en/__init__.py similarity index 82% rename from g2p/en/__init__.py rename to parakeet/g2p/en/__init__.py index 912f2ae..92faf11 100644 --- a/g2p/en/__init__.py +++ b/parakeet/g2p/en/__init__.py @@ -1,8 +1,7 @@ # coding: utf-8 -from g2p.text.symbols import symbols -from g2p import text -from g2p.text import sequence_to_text +from ..text.symbols import symbols +from ..text import sequence_to_text import nltk from random import random @@ -30,7 +29,7 @@ def mix_pronunciation(text, p): def text_to_sequence(text, p=0.0): if p >= 0: text = mix_pronunciation(text, p) - from g2p.text import text_to_sequence + from ..text import text_to_sequence text = text_to_sequence(text, ["english_cleaners"]) return text diff --git a/g2p/es/__init__.py b/parakeet/g2p/es/__init__.py similarity index 61% rename from g2p/es/__init__.py rename to parakeet/g2p/es/__init__.py index d090468..fce4d18 100644 --- a/g2p/es/__init__.py +++ b/parakeet/g2p/es/__init__.py @@ -1,6 +1,6 @@ # coding: utf-8 -from g2p.text.symbols import symbols -from g2p.text import sequence_to_text +from ..text.symbols import symbols +from ..text import sequence_to_text import nltk from random import random @@ -9,7 +9,7 @@ n_vocab = len(symbols) def text_to_sequence(text, p=0.0): - from g2p.text import text_to_sequence + from ..text import text_to_sequence text = text_to_sequence(text, ["basic_cleaners"]) return text diff --git a/g2p/jp/__init__.py b/parakeet/g2p/jp/__init__.py similarity index 100% rename from g2p/jp/__init__.py rename to parakeet/g2p/jp/__init__.py diff --git a/g2p/ko/__init__.py b/parakeet/g2p/ko/__init__.py similarity index 100% rename from g2p/ko/__init__.py rename to parakeet/g2p/ko/__init__.py diff --git a/g2p/text/__init__.py b/parakeet/g2p/text/__init__.py similarity index 97% rename from g2p/text/__init__.py rename to parakeet/g2p/text/__init__.py index 0be6d4a..3942998 100644 --- a/g2p/text/__init__.py +++ b/parakeet/g2p/text/__init__.py @@ -1,6 +1,6 @@ import re -from g2p.text import cleaners -from g2p.text.symbols import symbols +from . import cleaners +from .symbols import symbols # Mappings from symbol to numeric ID and vice versa: diff --git a/g2p/text/cleaners.py b/parakeet/g2p/text/cleaners.py similarity index 100% rename from g2p/text/cleaners.py rename to parakeet/g2p/text/cleaners.py diff --git a/g2p/text/cmudict.py b/parakeet/g2p/text/cmudict.py similarity index 100% rename from g2p/text/cmudict.py rename to parakeet/g2p/text/cmudict.py diff --git a/g2p/text/numbers.py b/parakeet/g2p/text/numbers.py similarity index 100% rename from g2p/text/numbers.py rename to parakeet/g2p/text/numbers.py diff --git a/g2p/text/symbols.py b/parakeet/g2p/text/symbols.py similarity index 100% rename from g2p/text/symbols.py rename to parakeet/g2p/text/symbols.py diff --git a/parakeet/hparam_tf/__init__.py b/parakeet/hparam_tf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hparam_tf/hparam.py b/parakeet/hparam_tf/hparam.py similarity index 100% rename from hparam_tf/hparam.py rename to parakeet/hparam_tf/hparam.py diff --git a/hparam_tf/readme.md b/parakeet/hparam_tf/readme.md similarity index 100% rename from hparam_tf/readme.md rename to parakeet/hparam_tf/readme.md diff --git a/tests/test_ljspeech.py b/tests/test_ljspeech.py new file mode 100644 index 0000000..59061f8 --- /dev/null +++ b/tests/test_ljspeech.py @@ -0,0 +1,10 @@ +from parakeet.data.ljspeech import LJSpeech +from parakeet.data.datacargo import DataCargo + +from pathlib import Path + +LJSPEECH_ROOT = Path("/Users/chenfeiyu/projects/LJSpeech-1.1") +ljspeech = LJSpeech(LJSPEECH_ROOT) +ljspeech_cargo = DataCargo(ljspeech, batch_size=16, shuffle=True) +for i, batch in enumerate(ljspeech_cargo): + print(i) \ No newline at end of file