Skip to content

Commit f412184

Browse files
authoredJun 24, 2024··
doc: sync to latest grammar (#427)
1 parent 8235a46 commit f412184

File tree

11 files changed

+224
-86
lines changed

11 files changed

+224
-86
lines changed
 

‎ChatTTS/core.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def has_loaded(self, use_decoder = False):
4646

4747
for module in check_list:
4848
if not hasattr(self, module) and module not in self.pretrain_models:
49-
self.logger.warn(f'{module} not initialized.')
49+
self.logger.warning(f'{module} not initialized.')
5050
not_finish = True
5151

5252
if not not_finish:
@@ -75,7 +75,7 @@ def download_models(
7575
except:
7676
download_path = None
7777
if download_path is None or force_redownload:
78-
self.logger.log(logging.INFO, f'Download from HF: https://huggingface.co/2Noise/ChatTTS')
78+
self.logger.log(logging.INFO, f'download from HF: https://huggingface.co/2Noise/ChatTTS')
7979
try:
8080
download_path = snapshot_download(repo_id="2Noise/ChatTTS", allow_patterns=["*.pt", "*.yaml"])
8181
except:
@@ -232,7 +232,7 @@ def _load(
232232
try:
233233
gpt.gpt.forward = torch.compile(gpt.gpt.forward, backend='inductor', dynamic=True)
234234
except RuntimeError as e:
235-
self.logger.warning(f'Compile failed,{e}. fallback to normal mode.')
235+
self.logger.warning(f'compile failed: {e}. fallback to normal mode.')
236236
self.gpt = gpt
237237
spk_stat_path = os.path.join(os.path.dirname(gpt_ckpt_path), 'spk_stat.pt')
238238
assert os.path.exists(spk_stat_path), f'Missing spk_stat.pt: {spk_stat_path}'

‎ChatTTS/model/gpt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def generate(
412412
pbar.update(1)
413413

414414
if not finish.all():
415-
self.logger.warn(f'Incomplete result. hit max_new_token: {max_new_token}')
415+
self.logger.warning(f'incomplete result. hit max_new_token: {max_new_token}')
416416

417417
del finish
418418

‎ChatTTS/norm.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def __call__(
137137
text = self._apply_half2full_map(text)
138138
invalid_characters = self._count_invalid_characters(text)
139139
if len(invalid_characters):
140-
self.logger.warn(f'found invalid characters: {invalid_characters}')
140+
self.logger.warning(f'found invalid characters: {invalid_characters}')
141141
text = self._apply_character_map(text)
142142
if do_homophone_replacement:
143143
arr, replaced_words = _fast_replace(
@@ -153,10 +153,10 @@ def __call__(
153153

154154
def register(self, name: str, normalizer: Callable[[str], str]) -> bool:
155155
if name in self.normalizers:
156-
self.logger.warn(f"name {name} has been registered")
156+
self.logger.warning(f"name {name} has been registered")
157157
return False
158158
if not isinstance(normalizer, Callable[[str], str]):
159-
self.logger.warn("normalizer must have caller type (str) -> str")
159+
self.logger.warning("normalizer must have caller type (str) -> str")
160160
return False
161161
self.normalizers[name] = normalizer
162162
return True

‎ChatTTS/utils/gpu.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def select_device(min_memory=2047):
1818
device = torch.device('cpu')
1919
elif torch.backends.mps.is_available():
2020
# For Apple M1/M2 chips with Metal Performance Shaders
21-
logger.get_logger().info('Apple GPU found, using MPS.')
21+
logger.get_logger().info('apple GPU found, using MPS.')
2222
device = torch.device('mps')
2323
else:
24-
logger.get_logger().warning('No GPU found, use CPU instead')
24+
logger.get_logger().warning('no GPU found, use CPU instead')
2525
device = torch.device('cpu')
2626

2727
return device

‎README.md

+46-16
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ chat.load_models(compile=False) # Set to True for better performance
112112

113113
texts = ["PUT YOUR TEXT HERE",]
114114

115-
wavs = chat.infer(texts, )
115+
wavs = chat.infer(texts)
116116

117117
torchaudio.save("output1.wav", torch.from_numpy(wavs[0]), 24000)
118118
```
@@ -125,23 +125,27 @@ torchaudio.save("output1.wav", torch.from_numpy(wavs[0]), 24000)
125125

126126
rand_spk = chat.sample_random_speaker()
127127

128-
params_infer_code = {
129-
'spk_emb': rand_spk, # add sampled speaker
130-
'temperature': .3, # using custom temperature
131-
'top_P': 0.7, # top P decode
132-
'top_K': 20, # top K decode
133-
}
128+
params_infer_code = ChatTTS.Chat.InferCodeParams(
129+
spk_emb = rand_spk, # add sampled speaker
130+
temperature = .3, # using custom temperature
131+
top_P = 0.7, # top P decode
132+
top_K = 20, # top K decode
133+
)
134134

135135
###################################
136136
# For sentence level manual control.
137137

138138
# use oral_(0-9), laugh_(0-2), break_(0-7)
139139
# to generate special token in text to synthesize.
140-
params_refine_text = {
141-
'prompt': '[oral_2][laugh_0][break_6]'
142-
}
140+
params_refine_text = ChatTTS.Chat.RefineTextParams(
141+
prompt='[oral_2][laugh_0][break_6]',
142+
)
143143

144-
wavs = chat.infer(texts, params_refine_text=params_refine_text, params_infer_code=params_infer_code)
144+
wavs = chat.infer(
145+
texts,
146+
params_refine_text=params_refine_text,
147+
params_infer_code=params_infer_code,
148+
)
145149

146150
###################################
147151
# For word level manual control.
@@ -163,16 +167,42 @@ capabilities with precise control over prosodic elements [laugh]like like
163167
[uv_break] use the project responsibly at your own risk.[uv_break]
164168
""".replace('\n', '') # English is still experimental.
165169

166-
params_refine_text = {
167-
'prompt': '[oral_2][laugh_0][break_4]'
168-
}
169-
# audio_array_cn = chat.infer(inputs_cn, params_refine_text=params_refine_text)
170+
params_refine_text = ChatTTS.Chat.RefineTextParams(
171+
prompt='[oral_2][laugh_0][break_4]',
172+
)
173+
170174
audio_array_en = chat.infer(inputs_en, params_refine_text=params_refine_text)
171175
torchaudio.save("output3.wav", torch.from_numpy(audio_array_en[0]), 24000)
172176
```
177+
178+
<table>
179+
<tr>
180+
<td align="center">
181+
182+
**male speaker**
183+
184+
</td>
185+
<td align="center">
186+
187+
**female speaker**
188+
189+
</td>
190+
</tr>
191+
<tr>
192+
<td align="center">
193+
173194
[male speaker](https://github.com/2noise/ChatTTS/assets/130631963/e0f51251-db7f-4d39-a0e9-3e095bb65de1)
174195

196+
</td>
197+
<td align="center">
198+
175199
[female speaker](https://github.com/2noise/ChatTTS/assets/130631963/f5dcdd01-1091-47c5-8241-c4f6aaaa8bbd)
200+
201+
</td>
202+
</tr>
203+
</table>
204+
205+
176206
</details>
177207

178208
## FAQ
@@ -206,4 +236,4 @@ In the current released model, the only token-level control units are `[laugh]`,
206236

207237
![counter](https://counter.seku.su/cmoe?name=chattts&theme=mbs)
208238

209-
</div>
239+
</div>

‎examples/ipynb/colab.ipynb

+88-39
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"\n",
5252
"from ChatTTS import ChatTTS\n",
5353
"from ChatTTS.tools.logger import get_logger\n",
54+
"from ChatTTS.tools.normalizer import normalizer_en_nemo_text, normalizer_zh_tn\n",
5455
"from IPython.display import Audio"
5556
]
5657
},
@@ -71,27 +72,50 @@
7172
},
7273
"outputs": [],
7374
"source": [
74-
"chat = ChatTTS.Chat(get_logger(\"ChatTTS\"))"
75+
"logger = get_logger(\"ChatTTS\")\n",
76+
"chat = ChatTTS.Chat(logger, remove_exist=True)\n",
77+
"\n",
78+
"# try to load normalizer\n",
79+
"try:\n",
80+
" chat.normalizer.register(\"en\", normalizer_en_nemo_text())\n",
81+
"except:\n",
82+
" logger.warning('Package nemo_text_processing not found!')\n",
83+
" logger.warning(\n",
84+
" 'Run: conda install -c conda-forge pynini=2.1.5 && pip install nemo_text_processing',\n",
85+
" )\n",
86+
"try:\n",
87+
" chat.normalizer.register(\"zh\", normalizer_zh_tn())\n",
88+
"except:\n",
89+
" logger.warning('Package WeTextProcessing not found!')\n",
90+
" logger.warning(\n",
91+
" 'Run: conda install -c conda-forge pynini=2.1.5 && pip install WeTextProcessing',\n",
92+
" )"
7593
]
7694
},
7795
{
7896
"cell_type": "markdown",
79-
"metadata": {},
97+
"metadata": {
98+
"id": "3Ty427FZNH30"
99+
},
80100
"source": [
81101
"### Here are three choices for loading models:"
82102
]
83103
},
84104
{
85105
"cell_type": "markdown",
86-
"metadata": {},
106+
"metadata": {
107+
"id": "NInF7Lk1NH30"
108+
},
87109
"source": [
88110
"#### 1. Load models from Hugging Face:"
89111
]
90112
},
91113
{
92114
"cell_type": "code",
93115
"execution_count": null,
94-
"metadata": {},
116+
"metadata": {
117+
"id": "VVtNlNosNH30"
118+
},
95119
"outputs": [],
96120
"source": [
97121
"# use force_redownload=True if the weights have been updated.\n",
@@ -100,15 +124,19 @@
100124
},
101125
{
102126
"cell_type": "markdown",
103-
"metadata": {},
127+
"metadata": {
128+
"id": "AhBD5WUPNH30"
129+
},
104130
"source": [
105131
"#### 2. Load models from local directories 'asset' and 'config':"
106132
]
107133
},
108134
{
109135
"cell_type": "code",
110136
"execution_count": null,
111-
"metadata": {},
137+
"metadata": {
138+
"id": "83UwV6SGNH31"
139+
},
112140
"outputs": [],
113141
"source": [
114142
"chat.load_models()\n",
@@ -117,15 +145,19 @@
117145
},
118146
{
119147
"cell_type": "markdown",
120-
"metadata": {},
148+
"metadata": {
149+
"id": "c0qjGPNkNH31"
150+
},
121151
"source": [
122152
"#### 3. Load models from a custom path:"
123153
]
124154
},
125155
{
126156
"cell_type": "code",
127157
"execution_count": null,
128-
"metadata": {},
158+
"metadata": {
159+
"id": "oCSBx0Q7NH31"
160+
},
129161
"outputs": [],
130162
"source": [
131163
"# write the model path into custom_path\n",
@@ -134,15 +166,19 @@
134166
},
135167
{
136168
"cell_type": "markdown",
137-
"metadata": {},
169+
"metadata": {
170+
"id": "VoEki3XMNH31"
171+
},
138172
"source": [
139173
"### You can also unload models to save the memory"
140174
]
141175
},
142176
{
143177
"cell_type": "code",
144178
"execution_count": null,
145-
"metadata": {},
179+
"metadata": {
180+
"id": "3FdsTSxoNH31"
181+
},
146182
"outputs": [],
147183
"source": [
148184
"chat.unload()"
@@ -219,8 +255,13 @@
219255
},
220256
"outputs": [],
221257
"source": [
222-
"params_infer_code = {'prompt':'[speed_5]', 'temperature':.3}\n",
223-
"params_refine_text = {'prompt':'[oral_2][laugh_0][break_6]'}\n",
258+
"params_infer_code = ChatTTS.Chat.InferCodeParams(\n",
259+
" prompt='[speed_5]',\n",
260+
" temperature=.3,\n",
261+
")\n",
262+
"params_refine_text = ChatTTS.Chat.RefineTextParams(\n",
263+
" prompt='[oral_2][laugh_0][break_6]',\n",
264+
")\n",
224265
"\n",
225266
"wav = chat.infer('四川美食可多了,有麻辣火锅、宫保鸡丁、麻婆豆腐、担担面、回锅肉、夫妻肺片等,每样都让人垂涎三尺。', \\\n",
226267
" params_refine_text=params_refine_text, params_infer_code=params_infer_code)"
@@ -255,7 +296,9 @@
255296
"outputs": [],
256297
"source": [
257298
"rand_spk = chat.sample_random_speaker()\n",
258-
"params_infer_code = {'spk_emb' : rand_spk, }\n",
299+
"params_infer_code = ChatTTS.Chat.InferCodeParams(\n",
300+
" spk_emb=rand_spk,\n",
301+
")\n",
259302
"\n",
260303
"wav = chat.infer('四川美食确实以辣闻名,但也有不辣的选择。比如甜水面、赖汤圆、蛋烘糕、叶儿粑等,这些小吃口味温和,甜而不腻,也很受欢迎。', \\\n",
261304
" params_refine_text=params_refine_text, params_infer_code=params_infer_code)"
@@ -302,7 +345,7 @@
302345
},
303346
"outputs": [],
304347
"source": [
305-
"wav = chat.infer(refined_text)"
348+
"wav = chat.infer(refined_text, skip_refine_text=True)"
306349
]
307350
},
308351
{
@@ -316,80 +359,86 @@
316359
"Audio(wav[0], rate=24_000, autoplay=True)"
317360
]
318361
},
362+
{
363+
"cell_type": "markdown",
364+
"metadata": {
365+
"id": "GG5AMbQbbSrl"
366+
},
367+
"source": [
368+
"## LLM Call"
369+
]
370+
},
319371
{
320372
"cell_type": "code",
321373
"execution_count": null,
322374
"metadata": {
323-
"id": "R2WjuVrWbSrl"
375+
"id": "3rkfwc3UbSrl"
324376
},
325377
"outputs": [],
326378
"source": [
327-
"text = 'so we found being competitive and collaborative [uv_break] was a huge way of staying [uv_break] motivated towards our goals, [uv_break] so [uv_break] one person to call [uv_break] when you fall off, [uv_break] one person who [uv_break] gets you back [uv_break] on then [uv_break] one person [uv_break] to actually do the activity with.'\n",
328-
"wav = chat.infer(text, skip_refine_text=True)"
379+
"from ChatTTS.tools.llm import ChatOpenAI\n",
380+
"\n",
381+
"API_KEY = ''\n",
382+
"client = ChatOpenAI(api_key=API_KEY,\n",
383+
" base_url=\"https://api.deepseek.com\",\n",
384+
" model=\"deepseek-chat\")"
329385
]
330386
},
331387
{
332388
"cell_type": "code",
333389
"execution_count": null,
334390
"metadata": {
335-
"id": "71Y4pBdl-_Yd"
391+
"id": "TTkIsXozbSrm"
336392
},
337393
"outputs": [],
338394
"source": [
339-
"Audio(wav[0], rate=24_000, autoplay=True)"
395+
"user_question = '四川有哪些好吃的美食呢?'"
340396
]
341397
},
342398
{
343-
"cell_type": "markdown",
399+
"cell_type": "code",
400+
"execution_count": null,
344401
"metadata": {
345-
"id": "GG5AMbQbbSrl"
402+
"id": "3yT8uNz-RVy1"
346403
},
404+
"outputs": [],
347405
"source": [
348-
"## LLM Call"
406+
"text = client.call(user_question, prompt_version = 'deepseek')\n",
407+
"text"
349408
]
350409
},
351410
{
352411
"cell_type": "code",
353412
"execution_count": null,
354413
"metadata": {
355-
"id": "3rkfwc3UbSrl"
414+
"id": "6qddpv7lRW-3"
356415
},
357416
"outputs": [],
358417
"source": [
359-
"from ChatTTS.experimental.llm import llm_api\n",
360-
"\n",
361-
"API_KEY = ''\n",
362-
"client = llm_api(api_key=API_KEY,\n",
363-
" base_url=\"https://api.deepseek.com\",\n",
364-
" model=\"deepseek-chat\")"
418+
"text = client.call(text, prompt_version = 'deepseek_TN')\n",
419+
"text"
365420
]
366421
},
367422
{
368423
"cell_type": "code",
369424
"execution_count": null,
370425
"metadata": {
371-
"id": "TTkIsXozbSrm"
426+
"id": "qNhCJG4VbSrm"
372427
},
373428
"outputs": [],
374429
"source": [
375-
"user_question = '四川有哪些好吃的美食呢?'\n",
376-
"text = client.call(user_question, prompt_version = 'deepseek')\n",
377-
"print(text)\n",
378-
"text = client.call(text, prompt_version = 'deepseek_TN')\n",
379-
"print(text)"
430+
"wav = chat.infer(text)"
380431
]
381432
},
382433
{
383434
"cell_type": "code",
384435
"execution_count": null,
385436
"metadata": {
386-
"id": "qNhCJG4VbSrm"
437+
"id": "Wq1XQHmFRQI3"
387438
},
388439
"outputs": [],
389440
"source": [
390-
"params_infer_code = {'spk_emb' : rand_spk, 'temperature':.3}\n",
391-
"\n",
392-
"wav = chat.infer(text, params_infer_code=params_infer_code)"
441+
"Audio(wav[0], rate=24_000, autoplay=True)"
393442
]
394443
}
395444
],

‎examples/ipynb/example.ipynb

+72-15
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"\n",
3535
"import ChatTTS\n",
3636
"from tools.logger import get_logger\n",
37+
"from tools.normalizer import normalizer_en_nemo_text, normalizer_zh_tn\n",
3738
"from IPython.display import Audio"
3839
]
3940
},
@@ -52,7 +53,24 @@
5253
"source": [
5354
"os.chdir(root_dir)\n",
5455
"\n",
55-
"chat = ChatTTS.Chat(get_logger(\"ChatTTS\"))"
56+
"logger = get_logger(\"ChatTTS\")\n",
57+
"chat = ChatTTS.Chat(logger)\n",
58+
"\n",
59+
"# try to load normalizer\n",
60+
"try:\n",
61+
" chat.normalizer.register(\"en\", normalizer_en_nemo_text())\n",
62+
"except:\n",
63+
" logger.warning('Package nemo_text_processing not found!')\n",
64+
" logger.warning(\n",
65+
" 'Run: conda install -c conda-forge pynini=2.1.5 && pip install nemo_text_processing',\n",
66+
" )\n",
67+
"try:\n",
68+
" chat.normalizer.register(\"zh\", normalizer_zh_tn())\n",
69+
"except:\n",
70+
" logger.warning('Package WeTextProcessing not found!')\n",
71+
" logger.warning(\n",
72+
" 'Run: conda install -c conda-forge pynini=2.1.5 && pip install WeTextProcessing',\n",
73+
" )"
5674
]
5775
},
5876
{
@@ -186,8 +204,13 @@
186204
"metadata": {},
187205
"outputs": [],
188206
"source": [
189-
"params_infer_code = {'prompt':'[speed_5]', 'temperature':.3}\n",
190-
"params_refine_text = {'prompt':'[oral_2][laugh_0][break_6]'}\n",
207+
"params_infer_code = ChatTTS.Chat.InferCodeParams(\n",
208+
" prompt='[speed_5]',\n",
209+
" temperature=.3,\n",
210+
")\n",
211+
"params_refine_text = ChatTTS.Chat.RefineTextParams(\n",
212+
" prompt='[oral_2][laugh_0][break_6]',\n",
213+
")\n",
191214
"\n",
192215
"wav = chat.infer('四川美食可多了,有麻辣火锅、宫保鸡丁、麻婆豆腐、担担面、回锅肉、夫妻肺片等,每样都让人垂涎三尺。', \\\n",
193216
" params_refine_text=params_refine_text, params_infer_code=params_infer_code)"
@@ -216,7 +239,9 @@
216239
"outputs": [],
217240
"source": [
218241
"rand_spk = chat.sample_random_speaker()\n",
219-
"params_infer_code = {'spk_emb' : rand_spk, }\n",
242+
"params_infer_code = ChatTTS.Chat.InferCodeParams(\n",
243+
" spk_emb=rand_spk,\n",
244+
")\n",
220245
"\n",
221246
"wav = chat.infer('四川美食确实以辣闻名,但也有不辣的选择。比如甜水面、赖汤圆、蛋烘糕、叶儿粑等,这些小吃口味温和,甜而不腻,也很受欢迎。', \\\n",
222247
" params_refine_text=params_refine_text, params_infer_code=params_infer_code)"
@@ -245,7 +270,17 @@
245270
"outputs": [],
246271
"source": [
247272
"text = \"So we found being competitive and collaborative was a huge way of staying motivated towards our goals, so one person to call when you fall off, one person who gets you back on then one person to actually do the activity with.\"\n",
248-
"chat.infer(text, refine_text_only=True)"
273+
"refined_text = chat.infer(text, refine_text_only=True)\n",
274+
"refined_text"
275+
]
276+
},
277+
{
278+
"cell_type": "code",
279+
"execution_count": null,
280+
"metadata": {},
281+
"outputs": [],
282+
"source": [
283+
"wav = chat.infer(refined_text, skip_refine_text=True)"
249284
]
250285
},
251286
{
@@ -254,8 +289,7 @@
254289
"metadata": {},
255290
"outputs": [],
256291
"source": [
257-
"text = 'so we found being competitive and collaborative [uv_break] was a huge way of staying [uv_break] motivated towards our goals, [uv_break] so [uv_break] one person to call [uv_break] when you fall off, [uv_break] one person who [uv_break] gets you back [uv_break] on then [uv_break] one person [uv_break] to actually do the activity with.'\n",
258-
"wav = chat.infer(text, skip_refine_text=True)"
292+
"Audio(wav[0], rate=24_000, autoplay=True)"
259293
]
260294
},
261295
{
@@ -271,10 +305,10 @@
271305
"metadata": {},
272306
"outputs": [],
273307
"source": [
274-
"from ChatTTS.experimental.llm import llm_api\n",
308+
"from tools.llm import ChatOpenAI\n",
275309
"\n",
276310
"API_KEY = ''\n",
277-
"client = llm_api(api_key=API_KEY,\n",
311+
"client = ChatOpenAI(api_key=API_KEY,\n",
278312
" base_url=\"https://api.deepseek.com\",\n",
279313
" model=\"deepseek-chat\")"
280314
]
@@ -285,11 +319,27 @@
285319
"metadata": {},
286320
"outputs": [],
287321
"source": [
288-
"user_question = '四川有哪些好吃的美食呢?'\n",
322+
"user_question = '四川有哪些好吃的美食呢?'"
323+
]
324+
},
325+
{
326+
"cell_type": "code",
327+
"execution_count": null,
328+
"metadata": {},
329+
"outputs": [],
330+
"source": [
289331
"text = client.call(user_question, prompt_version = 'deepseek')\n",
290-
"print(text)\n",
332+
"text"
333+
]
334+
},
335+
{
336+
"cell_type": "code",
337+
"execution_count": null,
338+
"metadata": {},
339+
"outputs": [],
340+
"source": [
291341
"text = client.call(text, prompt_version = 'deepseek_TN')\n",
292-
"print(text)"
342+
"text"
293343
]
294344
},
295345
{
@@ -298,9 +348,16 @@
298348
"metadata": {},
299349
"outputs": [],
300350
"source": [
301-
"params_infer_code = {'spk_emb' : rand_spk, 'temperature':.3}\n",
302-
"\n",
303-
"wav = chat.infer(text, params_infer_code=params_infer_code)"
351+
"wav = chat.infer(text)"
352+
]
353+
},
354+
{
355+
"cell_type": "code",
356+
"execution_count": null,
357+
"metadata": {},
358+
"outputs": [],
359+
"source": [
360+
"Audio(wav[0], rate=24_000, autoplay=True)"
304361
]
305362
}
306363
],

‎examples/web/funcs.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ def load_chat(cust_path: Optional[str], coef: Optional[str]) -> bool:
5050
try:
5151
chat.normalizer.register("en", normalizer_en_nemo_text())
5252
except:
53-
logger.warn('Package nemo_text_processing not found!')
54-
logger.warn(
53+
logger.warning('Package nemo_text_processing not found!')
54+
logger.warning(
5555
'Run: conda install -c conda-forge pynini=2.1.5 && pip install nemo_text_processing',
5656
)
5757
try:
5858
chat.normalizer.register("zh", normalizer_zh_tn())
5959
except:
60-
logger.warn('Package WeTextProcessing not found!')
61-
logger.warn(
60+
logger.warning('Package WeTextProcessing not found!')
61+
logger.warning(
6262
'Run: conda install -c conda-forge pynini=2.1.5 && pip install WeTextProcessing',
6363
)
6464
return ret

‎tools/llm/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .llm import ChatOpenAI

‎ChatTTS/experimental/llm.py ‎tools/llm/llm.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from openai import OpenAI
32

43
prompt_dict = {
@@ -22,7 +21,7 @@
2221
],
2322
}
2423

25-
class llm_api:
24+
class ChatOpenAI:
2625
def __init__(self, api_key, base_url, model):
2726
self.client = OpenAI(
2827
api_key = api_key,

‎tools/logger/log.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ def format(self, record: logging.LogRecord):
5151
return logstr
5252

5353

54-
def get_logger(name: str, lv = logging.INFO):
54+
def get_logger(name: str, lv = logging.INFO, remove_exist=False):
5555
logger = logging.getLogger(name)
5656
logger.setLevel(lv)
57+
if remove_exist and logger.hasHandlers():
58+
logger.handlers.clear()
5759
if not logger.hasHandlers():
5860
syslog = logging.StreamHandler()
5961
syslog.setFormatter(Formatter())

0 commit comments

Comments
 (0)
Please sign in to comment.