load g2p map from repo
Browse files
tokenization_bert_vits2.py
CHANGED
@@ -21,6 +21,7 @@ from typing import Any, Dict, List, Optional, Tuple, Union
|
|
21 |
|
22 |
from transformers.tokenization_utils import PreTrainedTokenizer
|
23 |
from transformers.utils import is_phonemizer_available, logging
|
|
|
24 |
|
25 |
|
26 |
if is_phonemizer_available():
|
@@ -104,7 +105,9 @@ class BertVits2Tokenizer(PreTrainedTokenizer):
|
|
104 |
"""Converts a string of Chinese text into a list of phonemes and tones."""
|
105 |
from pypinyin import lazy_pinyin, Style
|
106 |
|
107 |
-
|
|
|
|
|
108 |
g2p = json.load(f)
|
109 |
|
110 |
phones = []
|
|
|
21 |
|
22 |
from transformers.tokenization_utils import PreTrainedTokenizer
|
23 |
from transformers.utils import is_phonemizer_available, logging
|
24 |
+
from transformers.utils import get_file_from_repo
|
25 |
|
26 |
|
27 |
if is_phonemizer_available():
|
|
|
105 |
"""Converts a string of Chinese text into a list of phonemes and tones."""
|
106 |
from pypinyin import lazy_pinyin, Style
|
107 |
|
108 |
+
g2p_file = get_file_from_repo(self.name_or_path, "zh_g2p.json", subfolder="data")
|
109 |
+
|
110 |
+
with open(g2p_file, encoding="utf-8") as f:
|
111 |
g2p = json.load(f)
|
112 |
|
113 |
phones = []
|