myshell-ai / MeloTTS

High-quality multi-lingual text-to-speech library by MyShell.ai. Support English, Spanish, French, Chinese, Japanese and Korean.
MIT License
3.97k stars 473 forks source link

I need to help for working MeloTTS Korean in apple silicon python 3.10.14 (pyenv, virtualenv) #119

Closed joygom closed 1 month ago

joygom commented 2 months ago

Hello.

V1 and V2 are working fine with any language without only Korean on apple silicon include Melo-ui and demo-notebooks of openvoice. Surly I installed FFmpeg and me cab-ko by brew and I edited some code for working on apple silicon, such as se_extractor.py (cpu, int8) And edited some codes what 'using mps' to 'using cpu' for working Chinese. But I can not figure out how to working Korean. I need to help for working MeloTTS Korean in apple silicon python 3.10.14 (pyenv, virtualenv)

It seems to important thing is hide. I failed find any code about install automatically python-mecab-ko after running Korean on Melo-ui. I don't know why requirements.txt only include mecab-python twice without python-mecab-ko. And I find it is working again, when I install MeloTTS again after uninstall mecab-python3. and I have a questions why it is working even still installed python-mecab-ko.

I appreciate let me how to working Korean of melo-ui on my MacBook. (apple silicon python 3.10.14) another languages working perfectly, I think it is really amazing.

this is error messages when running Korean in Melo-ui with web browser.


최근 텍스트 음성 변환 분야가 급속도로 발전하고 있습니다.

=========================== you have to install python-mecab-ko. install it... huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks... To disable this warning, you can either:

  • Avoid using tokenizers before the fork if possible
  • Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false) Collecting python-mecab-ko Using cached python_mecab_ko-1.3.5-cp310-cp310-macosx_11_0_arm64.whl (348 kB) Collecting python-mecab-ko-dic Using cached python_mecab_ko_dic-2.1.1.post2-py3-none-any.whl (34.5 MB) Installing collected packages: python-mecab-ko-dic, python-mecab-ko Successfully installed python-mecab-ko-1.3.5 python-mecab-ko-dic-2.1.1.post2

[notice] A new release of pip is available: 23.0.1 -> 24.0 [notice] To update, run: python3.10 -m pip install --upgrade pip you have to install python-mecab-ko. "pip install python-mecab-ko" Traceback (most recent call last): File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/gradio/queueing.py", line 527, in process_events response = await route_utils.call_process_api( File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/gradio/route_utils.py", line 270, in call_process_api output = await app.get_blocks().process_api( File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/gradio/blocks.py", line 1847, in process_api result = await self.call_function( File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/gradio/blocks.py", line 1433, in call_function prediction = await anyio.to_thread.run_sync( File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread return await future File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 851, in run result = context.run(func, args) File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/gradio/utils.py", line 788, in wrapper response = f(args, **kwargs) File "/Users/gom/dev/pyenv/3.10.14_OpenVoice2/MeloTTS/melo/app.py", line 33, in synthesize models[language].tts_to_file(text, models[language].hps.data.spk2id[speaker], bio, speed=speed, pbar=progress.tqdm, format='wav') File "/Users/gom/dev/pyenv/3.10.14_OpenVoice2/MeloTTS/melo/api.py", line 100, in tts_to_file bert, ja_bert, phones, tones, lang_ids = utils.get_text_for_tts_infer(t, language, self.hps, device, self.symbol_to_id) File "/Users/gom/dev/pyenv/3.10.14_OpenVoice2/MeloTTS/melo/utils.py", line 23, in get_text_for_tts_infer norm_text, phone, tone, word2ph = clean_text(text, language_str) File "/Users/gom/dev/pyenv/3.10.14_OpenVoice2/MeloTTS/melo/text/cleaner.py", line 12, in clean_text phones, tones, word2ph = language_module.g2p(norm_text) File "/Users/gom/dev/pyenv/3.10.14_OpenVoice2/MeloTTS/melo/text/korean.py", line 122, in g2p phonemes = korean_text_to_phonemes(text) File "/Users/gom/dev/pyenv/3.10.14_OpenVoice2/MeloTTS/melo/text/korean.py", line 69, in korean_text_to_phonemes text = g2p_kr(text) File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/g2pkk/g2pkk.py", line 129, in call string = annotate(string, self.mecab) File "/Users/gom/.pyenv/versions/3.10.14/envs/openvoice2/lib/python3.10/site-packages/g2pkk/utils.py", line 166, in annotate tokens = mecab.pos(string) AttributeError: 'NoneType' object has no attribute 'pos'


docker is fine working all language include Korean. but really very slow. messages is below.

Text split to sentences. 최근 텍스트 음성 변환 분야가 급속도로 발전하고 있습니다.

you have to install python-mecab-ko. install it... huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks... To disable this warning, you can either:

  • Avoid using tokenizers before the fork if possible
  • Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false) Collecting python-mecab-ko Downloading python_mecab_ko-1.3.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (558 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 558.3/558.3 kB 8.5 MB/s eta 0:00:00 Collecting python-mecab-ko-dic Downloading python_mecab_ko_dic-2.1.1.post2-py3-none-any.whl (34.5 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 34.5/34.5 MB 11.0 MB/s eta 0:00:00 Installing collected packages: python-mecab-ko-dic, python-mecab-ko Successfully installed python-mecab-ko-1.3.5 python-mecab-ko-dic-2.1.1.post2 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.0.1 -> 24.0 [notice] To update, run: pip install --upgrade pip pytorch_model.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████| 476M/476M [00:41<00:00, 11.4MB/s] Some weights of the model checkpoint at kykim/bert-kor-base were not used when initializing BertForMaskedLM: ['cls.seq_relationship.bias', 'cls.seq_relationship.weight']

joygom commented 2 months ago

related issue (it closed without any solution) https://github.com/myshell-ai/MeloTTS/issues/113

joygom commented 2 months ago

I found the forder name ‘mecab’ and ‘MeCab’ in the docker. And I realize they are same on my mac, because mac filesystem setted case insensitive. I guess this is the reason why making error on mac when try korean on melo-ui. Saddly I can not format my filesystem, and I don’t know how edit code. Otherwise it will be no problem on linux with case sensitive file system maybe..

joygom commented 1 month ago

It is clear, working fine with using case sensitive filesystem on apple silicon. it is useless edit any code of git sources MeloTTS. Melo-ui working perfectly include Korean.