Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show all unused symbols before execution #281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions datasets/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
from datasets import audio
from tacotron.utils.text import get_unused_symbols
from wavenet_vocoder.util import is_mulaw, is_mulaw_quantize, mulaw, mulaw_quantize


Expand All @@ -29,16 +30,20 @@ def build_from_path(hparams, input_dirs, mel_dir, linear_dir, wav_dir, n_jobs=12
executor = ProcessPoolExecutor(max_workers=n_jobs)
futures = []
index = 1
unusedSymbols = set()
for input_dir in input_dirs:
with open(os.path.join(input_dir, 'metadata.csv'), encoding='utf-8') as f:
for line in f:
parts = line.strip().split('|')
basename = parts[0]
wav_path = os.path.join(input_dir, 'wavs', '{}.wav'.format(basename))
text = parts[2]
unusedSymbols |= get_unused_symbols(text)
futures.append(executor.submit(partial(_process_utterance, mel_dir, linear_dir, wav_dir, basename, wav_path, text, hparams)))
index += 1

print('Unused symbols in input data: {}'.format(str(unusedSymbols)))

return [future.result() for future in tqdm(futures) if future.result() is not None]


Expand Down
8 changes: 7 additions & 1 deletion tacotron/feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tensorflow as tf
from infolog import log
from sklearn.model_selection import train_test_split
from tacotron.utils.text import text_to_sequence
from tacotron.utils.text import text_to_sequence, get_unused_symbols

_batches_per_group = 64

Expand All @@ -33,6 +33,12 @@ def __init__(self, coordinator, metadata_filename, hparams):
hours = sum([int(x[4]) for x in self._metadata]) * frame_shift_ms / (3600)
log('Loaded metadata for {} examples ({:.2f} hours)'.format(len(self._metadata), hours))

# Check unused chars
unusedSymbols = set()
for m in self._metadata:
unusedSymbols |= get_unused_symbols(m[5])
log('Unused symbols in training data: {}'.format(str(unusedSymbols)))

#Train test split
if hparams.tacotron_test_size is None:
assert hparams.tacotron_test_batches is not None
Expand Down
7 changes: 7 additions & 0 deletions tacotron/utils/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def sequence_to_text(sequence):
result += s
return result.replace('}{', ' ')

def get_unused_symbols(text):
unused = set()
for s in text:
if not _should_keep_symbol(s):
unused.add(s)
return unused


def _clean_text(text, cleaner_names):
for name in cleaner_names:
Expand Down