Skip to content

Commit

Permalink
fix for train scripts and synthesize scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
yt605155624 committed Feb 1, 2023
1 parent 78c0db4 commit 82b5b8b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions paddlespeech/cli/tts/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ def _init_from_path(
with open(self.voc_config) as f:
self.voc_config = CfgNode(yaml.safe_load(f))

with open(self.phones_dict, "rt", encoding='utf-8') as f:
with open(self.phones_dict, 'rt', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)

tone_size = None
if self.tones_dict:
with open(self.tones_dict, "rt", encoding='utf-8') as f:
with open(self.tones_dict, 'rt', encoding='utf-8') as f:
tone_id = [line.strip().split() for line in f.readlines()]
tone_size = len(tone_id)

Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/t2s/exps/ernie_sat/synthesize_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def parse_args():

vocab_phones = {}

with open(args.phones_dict, 'rt') as f:
with open(args.phones_dict, 'rt', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
for phn, id in phn_id:
vocab_phones[phn] = int(id)
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/t2s/exps/ernie_sat/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def train_sp(args, config):
num_workers=config.num_workers)
print("dataloaders done!")

with open(args.phones_dict, "r") as f:
with open(args.phones_dict, 'r', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)
print("vocab_size:", vocab_size)
Expand Down
4 changes: 2 additions & 2 deletions paddlespeech/t2s/exps/fastspeech2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def train_sp(args, config):
if args.speaker_dict is not None:
print("multiple speaker fastspeech2!")
collate_fn = fastspeech2_multi_spk_batch_fn
with open(args.speaker_dict, 'rt') as f:
with open(args.speaker_dict, 'rt', encoding='utf-8') as f:
spk_id = [line.strip().split() for line in f.readlines()]
spk_num = len(spk_id)
fields += ["spk_id"]
Expand Down Expand Up @@ -123,7 +123,7 @@ def train_sp(args, config):
num_workers=config.num_workers)
print("dataloaders done!")

with open(args.phones_dict, "r") as f:
with open(args.phones_dict, 'rt', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)
print("vocab_size:", vocab_size)
Expand Down
6 changes: 3 additions & 3 deletions paddlespeech/t2s/exps/speedyspeech/synthesize_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ def evaluate(args, speedyspeech_config, pwg_config):

# construct dataset for evaluation
sentences = []
with open(args.text, 'rt') as f:
with open(args.text, 'rt', encoding='utf-8') as f:
for line in f:
items = line.strip().split()
utt_id = items[0]
sentence = "".join(items[1:])
sentences.append((utt_id, sentence))

with open(args.phones_dict, "r") as f:
with open(args.phones_dict, 'rt', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)
print("vocab_size:", vocab_size)
with open(args.tones_dict, "r") as f:
with open(args.tones_dict, 'rt', encoding='utf-8') as f:
tone_id = [line.strip().split() for line in f.readlines()]
tone_size = len(tone_id)
print("tone_size:", tone_size)
Expand Down
6 changes: 3 additions & 3 deletions paddlespeech/t2s/exps/speedyspeech/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def train_sp(args, config):
if args.speaker_dict is not None:
print("multiple speaker speedyspeech!")
collate_fn = speedyspeech_multi_spk_batch_fn
with open(args.speaker_dict, 'rt') as f:
with open(args.speaker_dict, 'rt', encoding='utf-8') as f:
spk_id = [line.strip().split() for line in f.readlines()]
spk_num = len(spk_id)
fields += ["spk_id"]
Expand Down Expand Up @@ -133,11 +133,11 @@ def train_sp(args, config):
collate_fn=collate_fn,
num_workers=config.num_workers)
print("dataloaders done!")
with open(args.phones_dict, "r") as f:
with open(args.phones_dict, 'rt', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)
print("vocab_size:", vocab_size)
with open(args.tones_dict, "r") as f:
with open(args.tones_dict, 'r', encoding='utf-8') as f:
tone_id = [line.strip().split() for line in f.readlines()]
tone_size = len(tone_id)
print("tone_size:", tone_size)
Expand Down
8 changes: 4 additions & 4 deletions paddlespeech/t2s/exps/syn_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_chunks(data, block_size: int, pad_size: int):
def get_sentences(text_file: Optional[os.PathLike], lang: str='zh'):
# construct dataset for evaluation
sentences = []
with open(text_file, 'rt') as f:
with open(text_file, 'rt', encoding='utf-8') as f:
for line in f:
if line.strip() != "":
items = re.split(r"\s+", line.strip(), 1)
Expand Down Expand Up @@ -325,17 +325,17 @@ def get_am_inference(am: str='fastspeech2_csmsc',
tones_dict: Optional[os.PathLike]=None,
speaker_dict: Optional[os.PathLike]=None,
return_am: bool=False):
with open(phones_dict, "r") as f:
with open(phones_dict, 'rt', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)
tone_size = None
if tones_dict is not None:
with open(tones_dict, "r") as f:
with open(tones_dict, 'rt', encoding='utf-8') as f:
tone_id = [line.strip().split() for line in f.readlines()]
tone_size = len(tone_id)
spk_num = None
if speaker_dict is not None:
with open(speaker_dict, 'rt') as f:
with open(speaker_dict, 'rt', encoding='utf-8') as f:
spk_id = [line.strip().split() for line in f.readlines()]
spk_num = len(spk_id)
odim = am_config.n_mels
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/t2s/exps/tacotron2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def train_sp(args, config):
num_workers=config.num_workers)
print("dataloaders done!")

with open(args.phones_dict, "r") as f:
with open(args.phones_dict, 'rt', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)
print("vocab_size:", vocab_size)
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/t2s/exps/transformer_tts/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def train_sp(args, config):
num_workers=config.num_workers)
print("dataloaders done!")

with open(args.phones_dict, "r") as f:
with open(args.phones_dict, 'r', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)
print("vocab_size:", vocab_size)
Expand Down
4 changes: 2 additions & 2 deletions paddlespeech/t2s/exps/vits/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def train_sp(args, config):
if args.speaker_dict is not None:
print("multiple speaker vits!")
collate_fn = vits_multi_spk_batch_fn
with open(args.speaker_dict, 'rt') as f:
with open(args.speaker_dict, 'rt', encoding='utf-8') as f:
spk_id = [line.strip().split() for line in f.readlines()]
spk_num = len(spk_id)
fields += ["spk_id"]
Expand Down Expand Up @@ -132,7 +132,7 @@ def train_sp(args, config):
num_workers=config.num_workers)
print("dataloaders done!")

with open(args.phones_dict, "r") as f:
with open(args.phones_dict, 'rt', encoding='utf-8') as f:
phn_id = [line.strip().split() for line in f.readlines()]
vocab_size = len(phn_id)
print("vocab_size:", vocab_size)
Expand Down

0 comments on commit 82b5b8b

Please sign in to comment.