myshell-ai / MeloTTS

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

NLTK SSL ERRORS #153

Open fire17 opened 4 months ago

fire17 commented 4 months ago

Had a bunch of SSL errors could not download unidic, had to manually get it (See #62)

and also a bunch of nltk stuff that i had to download, but had errors when trying:

Traceback (most recent call last):
  File "/Users/magic/wholesomegarden/magicllight/magicllight/core/LocalTTS/melo_tts/melo_tts.py", line 17, in <module>
    model.tts_to_file(text, speaker_ids['EN-US'], output_path, speed=speed)
  File "/Users/magic/wholesomegarden/magicllight/magicllight/core/LocalTTS/melo_tts/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/magic/wholesomegarden/magicllight/magicllight/core/LocalTTS/melo_tts/MeloTTS/melo/utils.py", line 23, in get_text_for_tts_infer
    norm_text, phone, tone, word2ph = clean_text(text, language_str)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/magic/wholesomegarden/magicllight/magicllight/core/LocalTTS/melo_tts/MeloTTS/melo/text/cleaner.py", line 12, in clean_text
    phones, tones, word2ph = language_module.g2p(norm_text)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/magic/wholesomegarden/magicllight/magicllight/core/LocalTTS/melo_tts/MeloTTS/melo/text/english.py", line 242, in g2p
    phone_list = list(filter(lambda p: p != " ", _g2p(w)))
                                                 ^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/g2p_en/g2p.py", line 163, in __call__
    tokens = pos_tag(words)  # tuples of (word, tag)
             ^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nltk/tag/__init__.py", line 165, in pos_tag
    tagger = _get_tagger(lang)
             ^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nltk/tag/__init__.py", line 107, in _get_tagger
    tagger = PerceptronTagger()
             ^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nltk/tag/perceptron.py", line 167, in __init__
    find("taggers/averaged_perceptron_tagger/" + PICKLE)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nltk/data.py", line 583, in find
    raise LookupError(resource_not_found)
LookupError: 
**********************************************************************
  Resource averaged_perceptron_tagger not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('averaged_perceptron_tagger')

  For more information see: https://www.nltk.org/data.html

  Attempted to load taggers/averaged_perceptron_tagger/averaged_perceptron_tagger.pickle

  Searched in:
    - '/Users/magic/nltk_data'
    - '/Library/Frameworks/Python.framework/Versions/3.11/nltk_data'
    - '/Library/Frameworks/Python.framework/Versions/3.11/share/nltk_data'
    - '/Library/Frameworks/Python.framework/Versions/3.11/lib/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
**********************************************************************

magic@Tamis-MacBook-Pro melo_tts % python3.11
Python 3.11.9 (v3.11.9:de54cf5be3, Apr  2 2024, 07:12:50) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ntlk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ntlk'
>>> import ntlk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ntlk'
>>> import nltk
>>> nltk.download('averaged_perceptron_tagger')
[nltk_data] Error loading averaged_perceptron_tagger: <urlopen error
[nltk_data]     [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify
[nltk_data]     failed: unable to get local issuer certificate
[nltk_data]     (_ssl.c:1006)>
False

[cmudict, averaged_perceptron_tagger]

Finally this helped:

import nltk
import ssl

try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    pass
else:
    ssl._create_default_https_context = _create_unverified_https_context

nltk.download()

this should open the nltk console, go to All packages, and install what you need putting this here incase anyone is searching for this and also maybe @myshell-ai will address this

thanks a lot and all the best

Seneko commented 2 months ago

Thanks , this helped me for missing "averaged_perceptron_tagger_eng", while other langs were working.

lukaLLM commented 3 weeks ago

Thanks, you helped me to make it work on windows!