xinference 1.2.0__py3-none-any.whl → 1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xinference might be problematic. Click here for more details.

Files changed (124) hide show
  1. xinference/_version.py +3 -3
  2. xinference/api/restful_api.py +4 -7
  3. xinference/client/handlers.py +3 -0
  4. xinference/core/chat_interface.py +6 -1
  5. xinference/core/model.py +2 -0
  6. xinference/core/scheduler.py +4 -7
  7. xinference/core/supervisor.py +114 -23
  8. xinference/core/worker.py +70 -4
  9. xinference/deploy/local.py +2 -1
  10. xinference/model/audio/core.py +11 -0
  11. xinference/model/audio/cosyvoice.py +16 -5
  12. xinference/model/audio/kokoro.py +139 -0
  13. xinference/model/audio/melotts.py +110 -0
  14. xinference/model/audio/model_spec.json +80 -0
  15. xinference/model/audio/model_spec_modelscope.json +18 -0
  16. xinference/model/audio/whisper.py +35 -10
  17. xinference/model/llm/llama_cpp/core.py +21 -14
  18. xinference/model/llm/llm_family.json +527 -1
  19. xinference/model/llm/llm_family.py +4 -1
  20. xinference/model/llm/llm_family_modelscope.json +495 -3
  21. xinference/model/llm/memory.py +1 -1
  22. xinference/model/llm/mlx/core.py +24 -6
  23. xinference/model/llm/transformers/core.py +9 -1
  24. xinference/model/llm/transformers/qwen2_audio.py +3 -1
  25. xinference/model/llm/transformers/qwen2_vl.py +20 -3
  26. xinference/model/llm/transformers/utils.py +22 -11
  27. xinference/model/llm/utils.py +115 -1
  28. xinference/model/llm/vllm/core.py +14 -4
  29. xinference/model/llm/vllm/xavier/block.py +3 -4
  30. xinference/model/llm/vllm/xavier/block_tracker.py +71 -58
  31. xinference/model/llm/vllm/xavier/collective.py +74 -0
  32. xinference/model/llm/vllm/xavier/collective_manager.py +147 -0
  33. xinference/model/llm/vllm/xavier/executor.py +18 -16
  34. xinference/model/llm/vllm/xavier/scheduler.py +79 -63
  35. xinference/model/llm/vllm/xavier/test/test_xavier.py +60 -35
  36. xinference/model/llm/vllm/xavier/transfer.py +53 -32
  37. xinference/thirdparty/cosyvoice/bin/spk2info.pt +0 -0
  38. xinference/thirdparty/melo/__init__.py +0 -0
  39. xinference/thirdparty/melo/api.py +135 -0
  40. xinference/thirdparty/melo/app.py +61 -0
  41. xinference/thirdparty/melo/attentions.py +459 -0
  42. xinference/thirdparty/melo/commons.py +160 -0
  43. xinference/thirdparty/melo/configs/config.json +94 -0
  44. xinference/thirdparty/melo/data/example/metadata.list +20 -0
  45. xinference/thirdparty/melo/data_utils.py +413 -0
  46. xinference/thirdparty/melo/download_utils.py +67 -0
  47. xinference/thirdparty/melo/infer.py +25 -0
  48. xinference/thirdparty/melo/init_downloads.py +14 -0
  49. xinference/thirdparty/melo/losses.py +58 -0
  50. xinference/thirdparty/melo/main.py +36 -0
  51. xinference/thirdparty/melo/mel_processing.py +174 -0
  52. xinference/thirdparty/melo/models.py +1030 -0
  53. xinference/thirdparty/melo/modules.py +598 -0
  54. xinference/thirdparty/melo/monotonic_align/__init__.py +16 -0
  55. xinference/thirdparty/melo/monotonic_align/core.py +46 -0
  56. xinference/thirdparty/melo/preprocess_text.py +135 -0
  57. xinference/thirdparty/melo/split_utils.py +174 -0
  58. xinference/thirdparty/melo/text/__init__.py +35 -0
  59. xinference/thirdparty/melo/text/chinese.py +199 -0
  60. xinference/thirdparty/melo/text/chinese_bert.py +107 -0
  61. xinference/thirdparty/melo/text/chinese_mix.py +253 -0
  62. xinference/thirdparty/melo/text/cleaner.py +36 -0
  63. xinference/thirdparty/melo/text/cleaner_multiling.py +110 -0
  64. xinference/thirdparty/melo/text/cmudict.rep +129530 -0
  65. xinference/thirdparty/melo/text/cmudict_cache.pickle +0 -0
  66. xinference/thirdparty/melo/text/english.py +284 -0
  67. xinference/thirdparty/melo/text/english_bert.py +39 -0
  68. xinference/thirdparty/melo/text/english_utils/__init__.py +0 -0
  69. xinference/thirdparty/melo/text/english_utils/abbreviations.py +35 -0
  70. xinference/thirdparty/melo/text/english_utils/number_norm.py +97 -0
  71. xinference/thirdparty/melo/text/english_utils/time_norm.py +47 -0
  72. xinference/thirdparty/melo/text/es_phonemizer/__init__.py +0 -0
  73. xinference/thirdparty/melo/text/es_phonemizer/base.py +140 -0
  74. xinference/thirdparty/melo/text/es_phonemizer/cleaner.py +109 -0
  75. xinference/thirdparty/melo/text/es_phonemizer/es_symbols.json +79 -0
  76. xinference/thirdparty/melo/text/es_phonemizer/es_symbols.txt +1 -0
  77. xinference/thirdparty/melo/text/es_phonemizer/es_symbols_v2.json +83 -0
  78. xinference/thirdparty/melo/text/es_phonemizer/es_to_ipa.py +12 -0
  79. xinference/thirdparty/melo/text/es_phonemizer/example_ipa.txt +400 -0
  80. xinference/thirdparty/melo/text/es_phonemizer/gruut_wrapper.py +253 -0
  81. xinference/thirdparty/melo/text/es_phonemizer/punctuation.py +174 -0
  82. xinference/thirdparty/melo/text/es_phonemizer/spanish_symbols.txt +1 -0
  83. xinference/thirdparty/melo/text/es_phonemizer/test.ipynb +124 -0
  84. xinference/thirdparty/melo/text/fr_phonemizer/__init__.py +0 -0
  85. xinference/thirdparty/melo/text/fr_phonemizer/base.py +140 -0
  86. xinference/thirdparty/melo/text/fr_phonemizer/cleaner.py +122 -0
  87. xinference/thirdparty/melo/text/fr_phonemizer/en_symbols.json +78 -0
  88. xinference/thirdparty/melo/text/fr_phonemizer/example_ipa.txt +1 -0
  89. xinference/thirdparty/melo/text/fr_phonemizer/fr_symbols.json +89 -0
  90. xinference/thirdparty/melo/text/fr_phonemizer/fr_to_ipa.py +30 -0
  91. xinference/thirdparty/melo/text/fr_phonemizer/french_abbreviations.py +48 -0
  92. xinference/thirdparty/melo/text/fr_phonemizer/french_symbols.txt +1 -0
  93. xinference/thirdparty/melo/text/fr_phonemizer/gruut_wrapper.py +258 -0
  94. xinference/thirdparty/melo/text/fr_phonemizer/punctuation.py +172 -0
  95. xinference/thirdparty/melo/text/french.py +94 -0
  96. xinference/thirdparty/melo/text/french_bert.py +39 -0
  97. xinference/thirdparty/melo/text/japanese.py +647 -0
  98. xinference/thirdparty/melo/text/japanese_bert.py +49 -0
  99. xinference/thirdparty/melo/text/ko_dictionary.py +44 -0
  100. xinference/thirdparty/melo/text/korean.py +192 -0
  101. xinference/thirdparty/melo/text/opencpop-strict.txt +429 -0
  102. xinference/thirdparty/melo/text/spanish.py +122 -0
  103. xinference/thirdparty/melo/text/spanish_bert.py +39 -0
  104. xinference/thirdparty/melo/text/symbols.py +290 -0
  105. xinference/thirdparty/melo/text/tone_sandhi.py +769 -0
  106. xinference/thirdparty/melo/train.py +635 -0
  107. xinference/thirdparty/melo/train.sh +19 -0
  108. xinference/thirdparty/melo/transforms.py +209 -0
  109. xinference/thirdparty/melo/utils.py +424 -0
  110. xinference/types.py +2 -0
  111. xinference/web/ui/build/asset-manifest.json +3 -3
  112. xinference/web/ui/build/index.html +1 -1
  113. xinference/web/ui/build/static/js/{main.1eb206d1.js → main.b0936c54.js} +3 -3
  114. xinference/web/ui/build/static/js/main.b0936c54.js.map +1 -0
  115. xinference/web/ui/node_modules/.cache/babel-loader/a3ff866acddf34917a7ee399e0e571a4dfd8ba66d5057db885f243e16a6eb17d.json +1 -0
  116. {xinference-1.2.0.dist-info → xinference-1.2.2.dist-info}/METADATA +37 -27
  117. {xinference-1.2.0.dist-info → xinference-1.2.2.dist-info}/RECORD +122 -45
  118. xinference/web/ui/build/static/js/main.1eb206d1.js.map +0 -1
  119. xinference/web/ui/node_modules/.cache/babel-loader/2213d49de260e1f67c888081b18f120f5225462b829ae57c9e05a05cec83689d.json +0 -1
  120. /xinference/web/ui/build/static/js/{main.1eb206d1.js.LICENSE.txt → main.b0936c54.js.LICENSE.txt} +0 -0
  121. {xinference-1.2.0.dist-info → xinference-1.2.2.dist-info}/LICENSE +0 -0
  122. {xinference-1.2.0.dist-info → xinference-1.2.2.dist-info}/WHEEL +0 -0
  123. {xinference-1.2.0.dist-info → xinference-1.2.2.dist-info}/entry_points.txt +0 -0
  124. {xinference-1.2.0.dist-info → xinference-1.2.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,253 @@
1
+ import os
2
+ import re
3
+
4
+ import cn2an
5
+ from pypinyin import lazy_pinyin, Style
6
+
7
+ # from text.symbols import punctuation
8
+ from .symbols import language_tone_start_map
9
+ from .tone_sandhi import ToneSandhi
10
+ from .english import g2p as g2p_en
11
+ from transformers import AutoTokenizer
12
+
13
+ punctuation = ["!", "?", "…", ",", ".", "'", "-"]
14
+ current_file_path = os.path.dirname(__file__)
15
+ pinyin_to_symbol_map = {
16
+ line.split("\t")[0]: line.strip().split("\t")[1]
17
+ for line in open(os.path.join(current_file_path, "opencpop-strict.txt")).readlines()
18
+ }
19
+
20
+ import jieba.posseg as psg
21
+
22
+
23
+ rep_map = {
24
+ ":": ",",
25
+ ";": ",",
26
+ ",": ",",
27
+ "。": ".",
28
+ "!": "!",
29
+ "?": "?",
30
+ "\n": ".",
31
+ "·": ",",
32
+ "、": ",",
33
+ "...": "…",
34
+ "$": ".",
35
+ "“": "'",
36
+ "”": "'",
37
+ "‘": "'",
38
+ "’": "'",
39
+ "(": "'",
40
+ ")": "'",
41
+ "(": "'",
42
+ ")": "'",
43
+ "《": "'",
44
+ "》": "'",
45
+ "【": "'",
46
+ "】": "'",
47
+ "[": "'",
48
+ "]": "'",
49
+ "—": "-",
50
+ "~": "-",
51
+ "~": "-",
52
+ "「": "'",
53
+ "」": "'",
54
+ }
55
+
56
+ tone_modifier = ToneSandhi()
57
+
58
+
59
+ def replace_punctuation(text):
60
+ text = text.replace("嗯", "恩").replace("呣", "母")
61
+ pattern = re.compile("|".join(re.escape(p) for p in rep_map.keys()))
62
+ replaced_text = pattern.sub(lambda x: rep_map[x.group()], text)
63
+ replaced_text = re.sub(r"[^\u4e00-\u9fa5_a-zA-Z\s" + "".join(punctuation) + r"]+", "", replaced_text)
64
+ replaced_text = re.sub(r"[\s]+", " ", replaced_text)
65
+
66
+ return replaced_text
67
+
68
+
69
+ def g2p(text, impl='v2'):
70
+ pattern = r"(?<=[{0}])\s*".format("".join(punctuation))
71
+ sentences = [i for i in re.split(pattern, text) if i.strip() != ""]
72
+ if impl == 'v1':
73
+ _func = _g2p
74
+ elif impl == 'v2':
75
+ _func = _g2p_v2
76
+ else:
77
+ raise NotImplementedError()
78
+ phones, tones, word2ph = _func(sentences)
79
+ assert sum(word2ph) == len(phones)
80
+ # assert len(word2ph) == len(text) # Sometimes it will crash,you can add a try-catch.
81
+ phones = ["_"] + phones + ["_"]
82
+ tones = [0] + tones + [0]
83
+ word2ph = [1] + word2ph + [1]
84
+ return phones, tones, word2ph
85
+
86
+
87
+ def _get_initials_finals(word):
88
+ initials = []
89
+ finals = []
90
+ orig_initials = lazy_pinyin(word, neutral_tone_with_five=True, style=Style.INITIALS)
91
+ orig_finals = lazy_pinyin(
92
+ word, neutral_tone_with_five=True, style=Style.FINALS_TONE3
93
+ )
94
+ for c, v in zip(orig_initials, orig_finals):
95
+ initials.append(c)
96
+ finals.append(v)
97
+ return initials, finals
98
+
99
+ model_id = 'bert-base-multilingual-uncased'
100
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
101
+ def _g2p(segments):
102
+ phones_list = []
103
+ tones_list = []
104
+ word2ph = []
105
+ for seg in segments:
106
+ # Replace all English words in the sentence
107
+ # seg = re.sub("[a-zA-Z]+", "", seg)
108
+ seg_cut = psg.lcut(seg)
109
+ initials = []
110
+ finals = []
111
+ seg_cut = tone_modifier.pre_merge_for_modify(seg_cut)
112
+ for word, pos in seg_cut:
113
+ if pos == "eng":
114
+ initials.append(['EN_WORD'])
115
+ finals.append([word])
116
+ else:
117
+ sub_initials, sub_finals = _get_initials_finals(word)
118
+ sub_finals = tone_modifier.modified_tone(word, pos, sub_finals)
119
+ initials.append(sub_initials)
120
+ finals.append(sub_finals)
121
+
122
+ # assert len(sub_initials) == len(sub_finals) == len(word)
123
+ initials = sum(initials, [])
124
+ finals = sum(finals, [])
125
+ #
126
+ for c, v in zip(initials, finals):
127
+ if c == 'EN_WORD':
128
+ tokenized_en = tokenizer.tokenize(v)
129
+ phones_en, tones_en, word2ph_en = g2p_en(text=None, pad_start_end=False, tokenized=tokenized_en)
130
+ # apply offset to tones_en
131
+ tones_en = [t + language_tone_start_map['EN'] for t in tones_en]
132
+ phones_list += phones_en
133
+ tones_list += tones_en
134
+ word2ph += word2ph_en
135
+ else:
136
+ raw_pinyin = c + v
137
+ # NOTE: post process for pypinyin outputs
138
+ # we discriminate i, ii and iii
139
+ if c == v:
140
+ assert c in punctuation
141
+ phone = [c]
142
+ tone = "0"
143
+ word2ph.append(1)
144
+ else:
145
+ v_without_tone = v[:-1]
146
+ tone = v[-1]
147
+
148
+ pinyin = c + v_without_tone
149
+ assert tone in "12345"
150
+
151
+ if c:
152
+ # 多音节
153
+ v_rep_map = {
154
+ "uei": "ui",
155
+ "iou": "iu",
156
+ "uen": "un",
157
+ }
158
+ if v_without_tone in v_rep_map.keys():
159
+ pinyin = c + v_rep_map[v_without_tone]
160
+ else:
161
+ # 单音节
162
+ pinyin_rep_map = {
163
+ "ing": "ying",
164
+ "i": "yi",
165
+ "in": "yin",
166
+ "u": "wu",
167
+ }
168
+ if pinyin in pinyin_rep_map.keys():
169
+ pinyin = pinyin_rep_map[pinyin]
170
+ else:
171
+ single_rep_map = {
172
+ "v": "yu",
173
+ "e": "e",
174
+ "i": "y",
175
+ "u": "w",
176
+ }
177
+ if pinyin[0] in single_rep_map.keys():
178
+ pinyin = single_rep_map[pinyin[0]] + pinyin[1:]
179
+
180
+ assert pinyin in pinyin_to_symbol_map.keys(), (pinyin, seg, raw_pinyin)
181
+ phone = pinyin_to_symbol_map[pinyin].split(" ")
182
+ word2ph.append(len(phone))
183
+
184
+ phones_list += phone
185
+ tones_list += [int(tone)] * len(phone)
186
+ return phones_list, tones_list, word2ph
187
+
188
+
189
+ def text_normalize(text):
190
+ numbers = re.findall(r"\d+(?:\.?\d+)?", text)
191
+ for number in numbers:
192
+ text = text.replace(number, cn2an.an2cn(number), 1)
193
+ text = replace_punctuation(text)
194
+ return text
195
+
196
+
197
+ def get_bert_feature(text, word2ph, device):
198
+ from . import chinese_bert
199
+ return chinese_bert.get_bert_feature(text, word2ph, model_id='bert-base-multilingual-uncased', device=device)
200
+
201
+ from .chinese import _g2p as _chinese_g2p
202
+ def _g2p_v2(segments):
203
+ spliter = '#$&^!@'
204
+
205
+ phones_list = []
206
+ tones_list = []
207
+ word2ph = []
208
+
209
+ for text in segments:
210
+ assert spliter not in text
211
+ # replace all english words
212
+ text = re.sub('([a-zA-Z\s]+)', lambda x: f'{spliter}{x.group(1)}{spliter}', text)
213
+ texts = text.split(spliter)
214
+ texts = [t for t in texts if len(t) > 0]
215
+
216
+
217
+ for text in texts:
218
+ if re.match('[a-zA-Z\s]+', text):
219
+ # english
220
+ tokenized_en = tokenizer.tokenize(text)
221
+ phones_en, tones_en, word2ph_en = g2p_en(text=None, pad_start_end=False, tokenized=tokenized_en)
222
+ # apply offset to tones_en
223
+ tones_en = [t + language_tone_start_map['EN'] for t in tones_en]
224
+ phones_list += phones_en
225
+ tones_list += tones_en
226
+ word2ph += word2ph_en
227
+ else:
228
+ phones_zh, tones_zh, word2ph_zh = _chinese_g2p([text])
229
+ phones_list += phones_zh
230
+ tones_list += tones_zh
231
+ word2ph += word2ph_zh
232
+ return phones_list, tones_list, word2ph
233
+
234
+
235
+
236
+ if __name__ == "__main__":
237
+ # from text.chinese_bert import get_bert_feature
238
+
239
+ text = "NFT啊!chemistry 但是《原神》是由,米哈\游自主, [研发]的一款全.新开放世界.冒险游戏"
240
+ text = '我最近在学习machine learning,希望能够在未来的artificial intelligence领域有所建树。'
241
+ text = '今天下午,我们准备去shopping mall购物,然后晚上去看一场movie。'
242
+ text = '我们现在 also 能够 help 很多公司 use some machine learning 的 algorithms 啊!'
243
+ text = text_normalize(text)
244
+ print(text)
245
+ phones, tones, word2ph = g2p(text, impl='v2')
246
+ bert = get_bert_feature(text, word2ph, device='cuda:0')
247
+ print(phones)
248
+ import pdb; pdb.set_trace()
249
+
250
+
251
+ # # 示例用法
252
+ # text = "这是一个示例文本:,你好!这是一个测试...."
253
+ # print(g2p_paddle(text)) # 输出: 这是一个示例文本你好这是一个测试
@@ -0,0 +1,36 @@
1
+ from . import chinese, japanese, english, chinese_mix, korean, french, spanish
2
+ from . import cleaned_text_to_sequence
3
+ import copy
4
+
5
+ language_module_map = {"ZH": chinese, "JP": japanese, "EN": english, 'ZH_MIX_EN': chinese_mix, 'KR': korean,
6
+ 'FR': french, 'SP': spanish, 'ES': spanish}
7
+
8
+
9
+ def clean_text(text, language):
10
+ language_module = language_module_map[language]
11
+ norm_text = language_module.text_normalize(text)
12
+ phones, tones, word2ph = language_module.g2p(norm_text)
13
+ return norm_text, phones, tones, word2ph
14
+
15
+
16
+ def clean_text_bert(text, language, device=None):
17
+ language_module = language_module_map[language]
18
+ norm_text = language_module.text_normalize(text)
19
+ phones, tones, word2ph = language_module.g2p(norm_text)
20
+
21
+ word2ph_bak = copy.deepcopy(word2ph)
22
+ for i in range(len(word2ph)):
23
+ word2ph[i] = word2ph[i] * 2
24
+ word2ph[0] += 1
25
+ bert = language_module.get_bert_feature(norm_text, word2ph, device=device)
26
+
27
+ return norm_text, phones, tones, word2ph_bak, bert
28
+
29
+
30
+ def text_to_sequence(text, language):
31
+ norm_text, phones, tones, word2ph = clean_text(text, language)
32
+ return cleaned_text_to_sequence(phones, tones, language)
33
+
34
+
35
+ if __name__ == "__main__":
36
+ pass
@@ -0,0 +1,110 @@
1
+ """Set of default text cleaners"""
2
+ # TODO: pick the cleaner for languages dynamically
3
+
4
+ import re
5
+
6
+ # Regular expression matching whitespace:
7
+ _whitespace_re = re.compile(r"\s+")
8
+
9
+ rep_map = {
10
+ ":": ",",
11
+ ";": ",",
12
+ ",": ",",
13
+ "。": ".",
14
+ "!": "!",
15
+ "?": "?",
16
+ "\n": ".",
17
+ "·": ",",
18
+ "、": ",",
19
+ "...": ".",
20
+ "…": ".",
21
+ "$": ".",
22
+ "“": "'",
23
+ "”": "'",
24
+ "‘": "'",
25
+ "’": "'",
26
+ "(": "'",
27
+ ")": "'",
28
+ "(": "'",
29
+ ")": "'",
30
+ "《": "'",
31
+ "》": "'",
32
+ "【": "'",
33
+ "】": "'",
34
+ "[": "'",
35
+ "]": "'",
36
+ "—": "",
37
+ "~": "-",
38
+ "~": "-",
39
+ "「": "'",
40
+ "」": "'",
41
+ }
42
+
43
+ def replace_punctuation(text):
44
+ pattern = re.compile("|".join(re.escape(p) for p in rep_map.keys()))
45
+ replaced_text = pattern.sub(lambda x: rep_map[x.group()], text)
46
+ return replaced_text
47
+
48
+ def lowercase(text):
49
+ return text.lower()
50
+
51
+
52
+ def collapse_whitespace(text):
53
+ return re.sub(_whitespace_re, " ", text).strip()
54
+
55
+ def remove_punctuation_at_begin(text):
56
+ return re.sub(r'^[,.!?]+', '', text)
57
+
58
+ def remove_aux_symbols(text):
59
+ text = re.sub(r"[\<\>\(\)\[\]\"\«\»\']+", "", text)
60
+ return text
61
+
62
+
63
+ def replace_symbols(text, lang="en"):
64
+ """Replace symbols based on the lenguage tag.
65
+
66
+ Args:
67
+ text:
68
+ Input text.
69
+ lang:
70
+ Lenguage identifier. ex: "en", "fr", "pt", "ca".
71
+
72
+ Returns:
73
+ The modified text
74
+ example:
75
+ input args:
76
+ text: "si l'avi cau, diguem-ho"
77
+ lang: "ca"
78
+ Output:
79
+ text: "si lavi cau, diguemho"
80
+ """
81
+ text = text.replace(";", ",")
82
+ text = text.replace("-", " ") if lang != "ca" else text.replace("-", "")
83
+ text = text.replace(":", ",")
84
+ if lang == "en":
85
+ text = text.replace("&", " and ")
86
+ elif lang == "fr":
87
+ text = text.replace("&", " et ")
88
+ elif lang == "pt":
89
+ text = text.replace("&", " e ")
90
+ elif lang == "ca":
91
+ text = text.replace("&", " i ")
92
+ text = text.replace("'", "")
93
+ elif lang== "es":
94
+ text=text.replace("&","y")
95
+ text = text.replace("'", "")
96
+ return text
97
+
98
+ def unicleaners(text, cased=False, lang='en'):
99
+ """Basic pipeline for Portuguese text. There is no need to expand abbreviation and
100
+ numbers, phonemizer already does that"""
101
+ if not cased:
102
+ text = lowercase(text)
103
+ text = replace_punctuation(text)
104
+ text = replace_symbols(text, lang=lang)
105
+ text = remove_aux_symbols(text)
106
+ text = remove_punctuation_at_begin(text)
107
+ text = collapse_whitespace(text)
108
+ text = re.sub(r'([^\.,!\?\-…])$', r'\1.', text)
109
+ return text
110
+