Repository: PaddlePaddle/PaddleSpeech

Issue:
[TTS]特殊的句子及标点导致报错
For support and discussions, please use our [Discourse forums](https://github.com/PaddlePaddle/DeepSpeech/discussions).

If you've found a bug then please create an issue with the following information:

**Describe the bug**
特殊句式导致报错

**To Reproduce**
报错句子：`并且——说来会使他惭愧——是以庄重口气谈到的,`

**Expected behavior**
正常生成

**Screenshots**
```shell
Loading model cost 0.382 seconds.
DEBUG 2022-10-22 17:58:41,857 __init__.py:164] Loading model cost 0.382 seconds.
Prefix dict has been built successfully.
DEBUG 2022-10-22 17:58:41,857 __init__.py:166] Prefix dict has been built successfully.
[并且——说来会使他惭愧——是以庄重口气谈到的,] not in g2pW dict,use g2pM
Traceback (most recent call last):
  File "C:\Users\ming\Desktop\1\2.py", line 28, in <module>
    tts(text=text, output="output.wav")
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\cli\utils.py", line 328, in _warpper
    return executor_func(self, *args, **kwargs)
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\cli\tts\infer.py", line 684, in __call__
    self.infer(text=text, lang=lang, am=am, spk_id=spk_id)
  File "C:\Users\ming\envs\b-site\lib\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "C:\Users\ming\envs\b-site\lib\site-packages\paddle\fluid\dygraph\base.py", line 354, in _decorate_function
    return func(*args, **kwargs)
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\cli\tts\infer.py", line 445, in infer
    frontend_dict = run_frontend(
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\t2s\exps\syn_utils.py", line 195, in run_frontend
    input_ids = frontend.get_input_ids(
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\t2s\frontend\zh_frontend.py", line 517, in get_input_ids
    phonemes = self.get_phonemes(
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\t2s\frontend\zh_frontend.py", line 437, in get_phonemes
    phonemes = self._g2p(
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\t2s\frontend\zh_frontend.py", line 243, in _g2p
    sub_finals = self.tone_modifier.modified_tone(word, pos,
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\t2s\frontend\tone_sandhi.py", line 352, in modified_tone
    finals = self._neural_sandhi(word, pos, finals)
  File "c:\users\ming\envs\b-site\paddlespeech\paddlespeech\t2s\frontend\tone_sandhi.py", line 89, in _neural_sandhi
    finals[-1] = finals[-1][:-1] + "5"
IndexError: list index out of range
```



Discussion:
正则化时需要对 `——` 这个特殊符号进行过滤，欢迎提交 pr 修复

Resolving patch:
diff --git a/paddlespeech/t2s/frontend/zh_normalization/text_normlization.py b/paddlespeech/t2s/frontend/zh_normalization/text_normlization.py
--- a/paddlespeech/t2s/frontend/zh_normalization/text_normlization.py
+++ b/paddlespeech/t2s/frontend/zh_normalization/text_normlization.py
@@ -65,7 +65,7 @@ def _split(self, text: str, lang="zh") -> List[str]:
         if lang == "zh":
             text = text.replace(" ", "")
             # 过滤掉特殊字符
-            text = re.sub(r'[《》【】<=>{}()（）#&@“”^_|…\\]', '', text)
+            text = re.sub(r'[——《》【】<=>{}()（）#&@“”^_|…\\]', '', text)
         text = self.SENTENCE_SPLITOR.sub(r'\1\n', text)
         text = text.strip()
         sentences = [sentence.strip() for sentence in re.split(r'\n+', text)]
@@ -85,7 +85,33 @@ def _post_replace(self, sentence: str) -> str:
         sentence = sentence.replace('⑧', '八')
         sentence = sentence.replace('⑨', '九')
         sentence = sentence.replace('⑩', '十')
-
+        sentence = sentence.replace('α', '阿尔法')
+        sentence = sentence.replace('β', '贝塔')
+        sentence = sentence.replace('γ', '伽玛').replace('Γ', '伽玛')
+        sentence = sentence.replace('δ', '德尔塔').replace('Δ', '德尔塔')
+        sentence = sentence.replace('ε', '艾普西龙')
+        sentence = sentence.replace('ζ', '捷塔')
+        sentence = sentence.replace('η', '依塔')
+        sentence = sentence.replace('θ', '西塔').replace('Θ', '西塔')
+        sentence = sentence.replace('ι', '艾欧塔')
+        sentence = sentence.replace('κ', '喀帕')
+        sentence = sentence.replace('λ', '拉姆达').replace('Λ', '拉姆达')
+        sentence = sentence.replace('μ', '缪')
+        sentence = sentence.replace('ν', '拗')
+        sentence = sentence.replace('ξ', '克西').replace('Ξ', '克西')
+        sentence = sentence.replace('ο', '欧米克伦')
+        sentence = sentence.replace('π', '派').replace('Π', '派')
+        sentence = sentence.replace('ρ', '肉')
+        sentence = sentence.replace('ς', '西格玛').replace('Σ', '西格玛').replace(
+            'σ', '西格玛')
+        sentence = sentence.replace('τ', '套')
+        sentence = sentence.replace('υ', '宇普西龙')
+        sentence = sentence.replace('φ', '服艾').replace('Φ', '服艾')
+        sentence = sentence.replace('χ', '器')
+        sentence = sentence.replace('ψ', '普赛').replace('Ψ', '普赛')
+        sentence = sentence.replace('ω', '欧米伽').replace('Ω', '欧米伽')
+        # re filter special characters, have one more character "-" than line 68
+        sentence = re.sub(r'[-——《》【】<=>{}()（）#&@“”^_|…\\]', '', sentence)
         return sentence
 
     def normalize_sentence(self, sentence: str) -> str:
@@ -124,6 +150,5 @@ def normalize_sentence(self, sentence: str) -> str:
 
     def normalize(self, text: str) -> List[str]:
         sentences = self._split(text)
-
         sentences = [self.normalize_sentence(sent) for sent in sentences]
         return sentences


Test patch: