diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index e3b564f..5917527 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -3,6 +3,6 @@ "", "\\text" ], - "SelectedNode": "\\train.py", + "SelectedNode": "\\text\\cleaners.py", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index d7477be..c5f2171 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/.vs/vits/FileContentIndex/211e1f28-c38f-4713-a77b-09725dc4fdd8.vsidx b/.vs/vits/FileContentIndex/211e1f28-c38f-4713-a77b-09725dc4fdd8.vsidx new file mode 100644 index 0000000..ee3c84e Binary files /dev/null and b/.vs/vits/FileContentIndex/211e1f28-c38f-4713-a77b-09725dc4fdd8.vsidx differ diff --git a/.vs/vits/v17/.suo b/.vs/vits/v17/.suo index 37f2da6..5595f53 100644 Binary files a/.vs/vits/v17/.suo and b/.vs/vits/v17/.suo differ diff --git a/data_utils.py b/data_utils.py index 21064b4..4855699 100644 --- a/data_utils.py +++ b/data_utils.py @@ -215,7 +215,7 @@ def get_audio(self, filename): self.sampling_rate, self.hop_length, self.win_length, center=False) spec = torch.squeeze(spec, 0) - torch.save(spec, spec_filename, _use_new_zipfile_serialization=False) + torch.save(spec, spec_filename) return spec, audio_norm def get_text(self, text): diff --git a/text/__init__.py b/text/__init__.py index d89aa75..48ae82f 100644 --- a/text/__init__.py +++ b/text/__init__.py @@ -1,13 +1,11 @@ """ from https://github.com/keithito/tacotron """ from text import cleaners +from text.symbols import symbols -def initialize(symbols): - # Mappings from symbol to numeric ID and vice versa: - global _symbol_to_id - global _id_to_symbol - _symbol_to_id = {s: i for i, s in enumerate(symbols)} - _id_to_symbol = {i: s for i, s in enumerate(symbols)} +# Mappings from symbol to numeric ID and vice versa: +_symbol_to_id = {s: i for i, s in enumerate(symbols)} +_id_to_symbol = {i: s for i, s in enumerate(symbols)} def text_to_sequence(text, cleaner_names): diff --git a/text/cleaners.py b/text/cleaners.py index 690585c..00db1c7 100644 --- a/text/cleaners.py +++ b/text/cleaners.py @@ -295,7 +295,44 @@ def japanese_cleaners(text): def japanese_cleaners2(text): - return japanese_cleaners(text).replace('ts','ʦ') + '''Pipeline for notating accent in Japanese text.''' + '''Reference https://r9y9.github.io/ttslearn/latest/notebooks/ch10_Recipe-Tacotron.html''' + sentences = re.split(_japanese_marks, text) + marks = re.findall(_japanese_marks, text) + text = '' + for i, sentence in enumerate(sentences): + if re.match(_japanese_characters, sentence): + if text!='': + text+=' ' + labels = pyopenjtalk.extract_fullcontext(sentence) + for n, label in enumerate(labels): + phoneme = re.search(r'\-([^\+]*)\+', label).group(1) + if phoneme not in ['sil','pau']: + text += phoneme.replace('ch','ʧ').replace('sh','ʃ').replace('cl','Q').replace('ts','ʦ') + else: + continue + n_moras = int(re.search(r'/F:(\d+)_', label).group(1)) + a1 = int(re.search(r"/A:(\-?[0-9]+)\+", label).group(1)) + a2 = int(re.search(r"\+(\d+)\+", label).group(1)) + a3 = int(re.search(r"\+(\d+)/", label).group(1)) + if re.search(r'\-([^\+]*)\+', labels[n + 1]).group(1) in ['sil','pau']: + a2_next=-1 + else: + a2_next = int(re.search(r"\+(\d+)\+", labels[n + 1]).group(1)) + # Accent phrase boundary + if a3 == 1 and a2_next == 1: + text += ' ' + # Falling + elif a1 == 0 and a2_next == a2 + 1 and a2 != n_moras: + text += '↓' + # Rising + elif a2 == 1 and a2_next == 2: + text += '↑' + if i