Skip to content

Commit

Permalink
delete symbol.py
Browse files Browse the repository at this point in the history
  • Loading branch information
CjangCjengh committed Aug 14, 2022
1 parent 65dff1e commit e3e355d
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"",
"\\text"
],
"SelectedNode": "\\text\\cleaners.py",
"SelectedNode": "\\train.py",
"PreviewInSolutionExplorer": false
}
Binary file modified .vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
Binary file modified .vs/vits/v17/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
torch.save(spec, spec_filename, _use_new_zipfile_serialization=False)
return spec, audio_norm

def get_text(self, text):
Expand Down
10 changes: 6 additions & 4 deletions text/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
""" from https://github.com/keithito/tacotron """
from text import cleaners
from text.symbols import 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 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)}


def text_to_sequence(text, cleaner_names):
Expand Down
39 changes: 1 addition & 38 deletions text/cleaners.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,44 +295,7 @@ def japanese_cleaners(text):


def japanese_cleaners2(text):
'''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<len(marks):
text += unidecode(marks[i]).replace(' ','')
if re.match('[A-Za-z]',text[-1]):
text += '.'
return text
return japanese_cleaners(text).replace('ts','ʦ')


def korean_cleaners(text):
Expand Down
29 changes: 0 additions & 29 deletions text/symbols.py

This file was deleted.

6 changes: 4 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ast import Import
import os
import json
import argparse
Expand Down Expand Up @@ -36,7 +37,7 @@
kl_loss
)
from mel_processing import mel_spectrogram_torch, spec_to_mel_torch
from text.symbols import symbols
from text import initialize


torch.backends.cudnn.benchmark = True
Expand All @@ -52,6 +53,7 @@ def main():
os.environ['MASTER_PORT'] = '80000'

hps = utils.get_hparams()
initialize(hps.symbols)
mp.spawn(run, nprocs=n_gpus, args=(n_gpus, hps,))


Expand Down Expand Up @@ -86,7 +88,7 @@ def run(rank, n_gpus, hps):
drop_last=False, collate_fn=collate_fn)

net_g = SynthesizerTrn(
len(symbols),
hps.symbols,
hps.data.filter_length // 2 + 1,
hps.train.segment_size // hps.data.hop_length,
**hps.model).cuda(rank)
Expand Down
11 changes: 3 additions & 8 deletions train_ms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import os
import json
import argparse
import itertools
import math
import torch
from torch import nn, optim
from torch.nn import functional as F
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter
Expand All @@ -13,7 +8,6 @@
from torch.nn.parallel import DistributedDataParallel as DDP
from torch.cuda.amp import autocast, GradScaler

import librosa
import logging

logging.getLogger('numba').setLevel(logging.WARNING)
Expand All @@ -36,7 +30,7 @@
kl_loss
)
from mel_processing import mel_spectrogram_torch, spec_to_mel_torch
from text.symbols import symbols
from text import initialize


torch.backends.cudnn.benchmark = True
Expand All @@ -52,6 +46,7 @@ def main():
os.environ['MASTER_PORT'] = '80000'

hps = utils.get_hparams()
initialize(hps.symbols)
mp.spawn(run, nprocs=n_gpus, args=(n_gpus, hps,))


Expand Down Expand Up @@ -86,7 +81,7 @@ def run(rank, n_gpus, hps):
drop_last=False, collate_fn=collate_fn)

net_g = SynthesizerTrn(
len(symbols),
hps.symbols,
hps.data.filter_length // 2 + 1,
hps.train.segment_size // hps.data.hop_length,
n_speakers=hps.data.n_speakers,
Expand Down

0 comments on commit e3e355d

Please sign in to comment.