Skip to content

Commit 8a5f63a

Browse files
committed
🤗 Complete BakerProcessor and add private processor_name to base_processor.
1 parent 71df49a commit 8a5f63a

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ ljspeech
3535
LibriTTS/
3636
dataset/
3737
mfa/
38-
kss
38+
kss/
39+
baker/

‎tensorflow_tts/processor/baker.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
from pypinyin.core import Pinyin
2929
from tensorflow_tts.processor import BaseProcessor
3030

31-
_pad = ["_"]
32-
_eos = ["~"]
31+
_pad = ["pad"]
32+
_eos = ["eos"]
3333
_pause = ["sil", "#0", "#1", "#2", "#3"]
3434

3535
_initials = [
@@ -546,6 +546,7 @@ class BakerProcessor(BaseProcessor):
546546
speaker_name: str = "baker"
547547

548548
def create_items(self):
549+
items = []
549550
if self.data_dir:
550551
with open(
551552
os.path.join(self.data_dir, "ProsodyLabeling/000001-010000.txt"),
@@ -561,13 +562,12 @@ def create_items(self):
561562
phonemes = self.get_phoneme_from_char_and_pinyin(chn_char, pinyin)
562563
wav_path = os.path.join(self.data_dir, "Wave", "%s.wav" % utt_id)
563564
items.append(
564-
[" ".join(phonemes), wav_path, self.speaker_name, utt_id]
565+
[" ".join(phonemes), wav_path, utt_id, self.speaker_name]
565566
)
566567
self.items = items
567568
self.pinyin_parser = self.get_pinyin_parser()
568569

569-
@staticmethod
570-
def get_phoneme_from_char_and_pinyin(chn_char, pinyin):
570+
def get_phoneme_from_char_and_pinyin(self, chn_char, pinyin):
571571
# we do not need #4, use sil to replace it
572572
chn_char = chn_char.replace("#4", "")
573573
char_len = len(chn_char)
@@ -613,7 +613,7 @@ def get_phoneme_from_char_and_pinyin(chn_char, pinyin):
613613
return result
614614

615615
def get_one_sample(self, item):
616-
text, wav_file, speaker_name, utt_id = item
616+
text, wav_file, utt_id, speaker_name = item
617617

618618
# normalize audio signal to be [-1, 1], soundfile already norm.
619619
audio, rate = sf.read(wav_file)

‎tensorflow_tts/processor/base_processor.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def __post_init__(self):
6161
self.create_symbols()
6262
if self.saved_mapper_path is not None:
6363
self._save_mapper(saved_path=self.saved_mapper_path)
64+
65+
# processor name. usefull to use it for AutoProcessor
66+
self._processor_name = type(self).__name__
6467

6568
def __getattr__(self, name: str) -> Union[str, int]:
6669
if "_id" in name: # map symbol to id
@@ -177,6 +180,7 @@ def _load_mapper(self, loaded_path: str = None):
177180
self.speakers_map = data["speakers_map"]
178181
self.symbol_to_id = data["symbol_to_id"]
179182
self.id_to_symbol = {int(k): v for k, v in data["id_to_symbol"].items()}
183+
self._processor_name = data["processor_name"]
180184

181185
# other keys
182186
all_data_keys = data.keys()
@@ -198,6 +202,7 @@ def _save_mapper(self, saved_path: str = None, extra_attrs_to_save: dict = None)
198202
"symbol_to_id": self.symbol_to_id,
199203
"id_to_symbol": self.id_to_symbol,
200204
"speakers_map": self.speakers_map,
205+
"processor_name": self._processor_name,
201206
}
202207
if extra_attrs_to_save:
203208
full_mapper = {**full_mapper, **extra_attrs_to_save}

0 commit comments

Comments
 (0)