Spaces:
Runtime error
Runtime error
Fix: use wetext on all platforms (avoid pynini dependency on Linux)
Browse files- indextts/utils/front.py +4 -5
indextts/utils/front.py
CHANGED
|
@@ -88,18 +88,17 @@ class TextNormalizer:
|
|
| 88 |
def load(self):
|
| 89 |
# print(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
|
| 90 |
# sys.path.append(model_dir)
|
| 91 |
-
import platform
|
| 92 |
if self.zh_normalizer is not None and self.en_normalizer is not None:
|
| 93 |
return
|
| 94 |
-
|
|
|
|
| 95 |
from wetext import Normalizer
|
| 96 |
-
|
| 97 |
self.zh_normalizer = Normalizer(remove_erhua=False, lang="zh", operator="tn")
|
| 98 |
self.en_normalizer = Normalizer(lang="en", operator="tn")
|
| 99 |
-
|
|
|
|
| 100 |
from tn.chinese.normalizer import Normalizer as NormalizerZh
|
| 101 |
from tn.english.normalizer import Normalizer as NormalizerEn
|
| 102 |
-
# use new cache dir for build tagger rules with disable remove_interjections and remove_erhua
|
| 103 |
cache_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tagger_cache")
|
| 104 |
if not os.path.exists(cache_dir):
|
| 105 |
os.makedirs(cache_dir)
|
|
|
|
| 88 |
def load(self):
|
| 89 |
# print(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
|
| 90 |
# sys.path.append(model_dir)
|
|
|
|
| 91 |
if self.zh_normalizer is not None and self.en_normalizer is not None:
|
| 92 |
return
|
| 93 |
+
# Try wetext first (pure Python, works everywhere including Docker/ZeroGPU)
|
| 94 |
+
try:
|
| 95 |
from wetext import Normalizer
|
|
|
|
| 96 |
self.zh_normalizer = Normalizer(remove_erhua=False, lang="zh", operator="tn")
|
| 97 |
self.en_normalizer = Normalizer(lang="en", operator="tn")
|
| 98 |
+
except ImportError:
|
| 99 |
+
# Fallback to WeTextProcessing (requires pynini)
|
| 100 |
from tn.chinese.normalizer import Normalizer as NormalizerZh
|
| 101 |
from tn.english.normalizer import Normalizer as NormalizerEn
|
|
|
|
| 102 |
cache_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tagger_cache")
|
| 103 |
if not os.path.exists(cache_dir):
|
| 104 |
os.makedirs(cache_dir)
|