Skip to content

Commit

Permalink
Fix for issues r9y9#37 and r9y9#53
Browse files Browse the repository at this point in the history
  • Loading branch information
Amila Rathnayake committed Mar 10, 2018
1 parent e615548 commit 5bd61ca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from matplotlib import pyplot as plt
import sys
import os
import platform
from tensorboardX import SummaryWriter
from matplotlib import cm
from warnings import warn
Expand Down Expand Up @@ -96,8 +97,9 @@ def plot_alignment(alignment, path, info=None):


class TextDataSource(FileDataSource):
def __init__(self, data_root, speaker_id=None):
def __init__(self, data_root, frontend_name, speaker_id=None):
self.data_root = data_root
self.frontend_name = frontend_name
self.speaker_ids = None
self.multi_speaker = False
# If not None, filter by speaker_id
Expand Down Expand Up @@ -130,6 +132,11 @@ def collect_features(self, *args):
text, speaker_id = args
else:
text = args[0]

# Fix for issues #37 and #53
if platform.system() == "Windows":
_frontend = getattr(frontend, self.frontend_name)

seq = _frontend.text_to_sequence(text, p=hparams.replace_pronunciation_prob)
if self.multi_speaker:
return np.asarray(seq, dtype=np.int32), int(speaker_id)
Expand Down Expand Up @@ -884,7 +891,7 @@ def restore_parts(path, model):
os.makedirs(checkpoint_dir, exist_ok=True)

# Input dataset definitions
X = FileSourceDataset(TextDataSource(data_root, speaker_id))
X = FileSourceDataset(TextDataSource(data_root, hparams.frontend, speaker_id))
Mel = FileSourceDataset(MelSpecDataSource(data_root, speaker_id))
Y = FileSourceDataset(LinearSpecDataSource(data_root, speaker_id))

Expand Down

0 comments on commit 5bd61ca

Please sign in to comment.