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

IO text encoding fix. #211

Open
wants to merge 2 commits 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
3 changes: 1 addition & 2 deletions infolog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
def init(filename, run_name, slack_url=None):
global _file, _run_name, _slack_url
_close_logfile()
_file = open(filename, 'a')
_file = open(filename, 'a')
_file = open(filename, 'a', encoding='utf-8')
_file.write('\n-----------------------------------------------------------------\n')
_file.write('Starting new {} training run\n'.format(run_name))
_file.write('-----------------------------------------------------------------\n')
Expand Down
6 changes: 3 additions & 3 deletions tacotron/synthesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def run_eval(args, checkpoint_path, output_dir, hparams, sentences):
sentences = [sentences[i: i+hparams.tacotron_synthesis_batch_size] for i in range(0, len(sentences), hparams.tacotron_synthesis_batch_size)]

log('Starting Synthesis')
with open(os.path.join(eval_dir, 'map.txt'), 'w') as file:
for i, texts in enumerate(tqdm(sentences)):
with open(os.path.join(eval_dir, 'map.txt'), 'w', encoding='utf-8') as file:
for i, text in enumerate(tqdm(sentences)):
start = time.time()
basenames = ['batch_{}_sentence_{}'.format(i, j) for j in range(len(texts))]
mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None)
Expand Down Expand Up @@ -101,7 +101,7 @@ def run_synthesis(args, checkpoint_path, output_dir, hparams):
log('Starting Synthesis')
mel_dir = os.path.join(args.input_dir, 'mels')
wav_dir = os.path.join(args.input_dir, 'audio')
with open(os.path.join(synth_dir, 'map.txt'), 'w') as file:
with open(os.path.join(synth_dir, 'map.txt'), 'w', encoding='utf-8') as file:
for i, meta in enumerate(tqdm(metadata)):
texts = [m[5] for m in meta]
mel_filenames = [os.path.join(mel_dir, m[1]) for m in meta]
Expand Down
2 changes: 1 addition & 1 deletion wavenet_vocoder/feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, coordinator, metadata_filename, base_dir, hparams):

#Load metadata
self._data_dir = os.path.dirname(metadata_filename)
with open(metadata_filename, 'r') as f:
with open(metadata_filename, 'r', encoding='utf-8') as f:
self._metadata = [line.strip().split('|') for line in f]

#Train test split
Expand Down
2 changes: 1 addition & 1 deletion wavenet_vocoder/synthesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def run_synthesis(args, checkpoint_path, output_dir, hparams):
speaker_ids = None if speaker_ids is None else [speaker_ids[i: i+hparams.wavenet_synthesis_batch_size] for i in range(0, len(speaker_ids), hparams.wavenet_synthesis_batch_size)]
texts = None if texts is None else [texts[i: i+hparams.wavenet_synthesis_batch_size] for i in range(0, len(texts), hparams.wavenet_synthesis_batch_size)]

with open(os.path.join(wav_dir, 'map.txt'), 'w') as file:
with open(os.path.join(wav_dir, 'map.txt'), 'w', encoding='utf-8') as file:
for i, mel_batch in enumerate(tqdm(mel_files)):
mel_spectros = [np.load(mel_file) for mel_file in mel_batch]

Expand Down