OpenVoice icon indicating copy to clipboard operation
OpenVoice copied to clipboard

nltk

Open aaron-sz opened this issue 1 year ago • 9 comments

Does anyone know any solutions to this problem? First it starts off with this:

C:\Users\me\Downloads\OpenVoiceProject\.venv\lib\site-packages\torch\nn\utils\weight_norm.py:143: FutureWarning: torch.nn.utils.weight_normis deprecated in favor oftorch.nn.utils.parametrizations.weight_norm. WeightNorm.apply(module, name, dim)

Then this:

File "C:\Users\me\Downloads\OpenVoiceProject\voice.py", line 42, in openvoice_v2 model.tts_to_file(text, speaker_id, src_path, speed=speed)

Which leads to:

File "C:\Users\me\Downloads\OpenVoiceProject\.venv\lib\site-packages\nltk\data.py", line 579, in find raise LookupError(resource_not_found)

Finally:

`LookupError:


Resource averaged_perceptron_tagger_eng not found. Please use the NLTK Downloader to obtain the resource:

import nltk nltk.download('averaged_perceptron_tagger_eng')

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

Attempted to load taggers/averaged_perceptron_tagger_eng/

Searched in: - 'C:\Users\me/nltk_data' - 'C:\Users\me\Downloads\OpenVoiceProject\.venv\nltk_data' - 'C:\Users\me\Downloads\OpenVoiceProject\.venv\share\nltk_data' - 'C:\Users\me\Downloads\OpenVoiceProject\.venv\lib\nltk_data' - 'C:\Users\me\AppData\Roaming\nltk_data' - 'C:\nltk_data' - 'D:\nltk_data' - 'E:\nltk_data' **********************************************************************`

aaron-sz avatar Nov 17 '24 02:11 aaron-sz

Quick Fix for NLTK Module LookupError

Solution

To resolve this, download the required resource using one of the following methods:


Option 1: Terminal Command

Run this in your terminal:

python -m nltk.downloader averaged_perceptron_tagger

Option 2: In Python Script

Add this to your Python code:

import nltk
nltk.download('averaged_perceptron_tagger')

This will ensure the required resource is downloaded and available for use.

kackcode avatar Nov 17 '24 11:11 kackcode

C:\Users\me\AppData\Local\Programs\Python\Python39\lib\runpy.py:127: RuntimeWarning: 'nltk.downloader' found in sys.modules after import of package 'nltk', but prior to execution of 'nltk.downloader'; this may result in unpredictable behaviour warn(RuntimeWarning(msg)) [nltk_data] Downloading package averaged_perceptron_tagger to [nltk_data] C:\Users\me\AppData\Roaming\nltk_data... [nltk_data] Package averaged_perceptron_tagger is already up-to- [nltk_data] date!

Was already updated and still does not work :( Here is the full terminal. I am on python 3.9.13

PS C:\Users\me\Downloads\OpenVoiceProject> & c:/Users/me/Downloads/OpenVoiceProject/.venv/Scripts/python.exe c:/Users/me/Downloads/OpenVoiceProject/main.py pygame 2.6.1 (SDL 2.28.4, Python 3.9.9) Hello from the pygame community. https://www.pygame.org/contribute.html C:\Users\me\Downloads\OpenVoiceProject\.venv\lib\site-packages\torch\nn\utils\weight_norm.py:143: FutureWarning: torch.nn.utils.weight_normis deprecated in favor oftorch.nn.utils.parametrizations.weight_norm. WeightNorm.apply(module, name, dim) C:\Users\me\Downloads\OpenVoiceProject\.venv\lib\site-packages\wavmark\__init__.py:16: FutureWarning: You are using torch.loadwithweights_only=False(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value forweights_onlywill be flipped toTrue. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=Truefor any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. checkpoint = torch.load(resume_path, map_location=torch.device('cpu')) c:\users\me\downloads\openvoiceproject\modules\openvoice\openvoice\api.py:36: FutureWarning: You are usingtorch.loadwithweights_only=False(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value forweights_onlywill be flipped toTrue. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=Truefor any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. checkpoint_dict = torch.load(ckpt_path, map_location=torch.device(self.device)) Loaded checkpoint 'modules\OpenVoice\checkpoints_v2\converter/checkpoint.pth' missing/unexpected keys: [] [] OpenVoice version: v2 [(0.0, 58.8188125)] after vad: dur = 58.81798185941043 C:\Users\me\Downloads\OpenVoiceProject\.venv\lib\site-packages\torch\functional.py:704: UserWarning: stft with return_complex=False is deprecated. In a future pytorch release, stft will return complex tensors for all inputs, and return_complex=False will raise an error. Note: you can still call torch.view_as_real on the complex output to recover the old return format. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\SpectralOps.cpp:878.) return _VF.stft( # type: ignore[attr-defined] C:\Users\me\Downloads\OpenVoiceProject\.venv\lib\site-packages\torch\nn\utils\weight_norm.py:143: FutureWarning:torch.nn.utils.weight_normis deprecated in favor oftorch.nn.utils.parametrizations.weight_norm. WeightNorm.apply(module, name, dim) c:\users\me\downloads\openvoiceproject\modules\melotts\melo\download_utils.py:64: FutureWarning: You are using torch.loadwithweights_only=False(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value forweights_onlywill be flipped toTrue. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=Truefor any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. return torch.load(ckpt_path, map_location=device) en-us c:\Users\me\Downloads\OpenVoiceProject\voice.py:41: FutureWarning: You are usingtorch.loadwithweights_only=False(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value forweights_onlywill be flipped toTrue. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. source_se = torch.load(f'modules/OpenVoice/checkpoints_v2/base_speakers/ses/{speaker_key}.pth', map_location=self._device)

Text split to sentences. Did you ever hear a folk tale about a giant turtle?

0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "c:\Users\me\Downloads\OpenVoiceProject\main.py", line 4, in vs.openvoice_v2() File "c:\Users\me\Downloads\OpenVoiceProject\voice.py", line 42, in openvoice_v2 model.tts_to_file(text, speaker_id, src_path, speed=speed) File "c:\users\me\downloads\openvoiceproject\modules\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 "c:\users\me\downloads\openvoiceproject\modules\melotts\melo\utils.py", line 23, in get_text_for_tts_infer norm_text, phone, tone, word2ph = clean_text(text, language_str) File "c:\users\me\downloads\openvoiceproject\modules\melotts\melo\text\cleaner.py", line 12, in clean_text phones, tones, word2ph = language_module.g2p(norm_text) File "c:\users\me\downloads\openvoiceproject\modules\melotts\melo\text\english.py", line 242, in g2p phone_list = list(filter(lambda p: p != " ", g2p(w))) File "C:\Users\me\Downloads\OpenVoiceProject.venv\lib\site-packages\g2p_en\g2p.py", line 162, in call tokens = pos_tag(words) # tuples of (word, tag) File "C:\Users\me\Downloads\OpenVoiceProject.venv\lib\site-packages\nltk\tag_init.py", line 168, in pos_tag tagger = get_tagger(lang) File "C:\Users\me\Downloads\OpenVoiceProject.venv\lib\site-packages\nltk\tag_init.py", line 110, in get_tagger tagger = PerceptronTagger() File "C:\Users\me\Downloads\OpenVoiceProject.venv\lib\site-packages\nltk\tag\perceptron.py", line 183, in init self.load_from_json(lang) File "C:\Users\me\Downloads\OpenVoiceProject.venv\lib\site-packages\nltk\tag\perceptron.py", line 273, in load_from_json loc = find(f"taggers/averaged_perceptron_tagger{lang}/") File "C:\Users\me\Downloads\OpenVoiceProject.venv\lib\site-packages\nltk\data.py", line 579, in find raise LookupError(resource_not_found) LookupError:


Resource averaged_perceptron_tagger_eng not found. Please use the NLTK Downloader to obtain the resource:

import nltk nltk.download('averaged_perceptron_tagger_eng')

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

Attempted to load taggers/averaged_perceptron_tagger_eng/

Searched in: - 'C:\Users\me/nltk_data' - 'C:\Users\me\Downloads\OpenVoiceProject\.venv\nltk_data' - 'C:\Users\me\Downloads\OpenVoiceProject\.venv\share\nltk_data' - 'C:\Users\me\Downloads\OpenVoiceProject\.venv\lib\nltk_data' - 'C:\Users\me\AppData\Roaming\nltk_data' - 'C:\nltk_data' - 'D:\nltk_data' - 'E:\nltk_data' **********************************************************************`

aaron-sz avatar Nov 17 '24 23:11 aaron-sz

I have the same issue, +1

Georg-code avatar Nov 17 '24 23:11 Georg-code

👉 Well, here is how it can be solved w.r.t a Linux system,

  1. Go to nltk_data and download averaged_perceptron_tagger_eng

  2. Unzip all the *.json files in the folder $HOME/nltk_data/taggers/averaged_perceptron_tagger_eng

  3. Re-run the model

☕ Hope, maybe it helps !

JustABeginning avatar Jan 10 '25 19:01 JustABeginning

downloading the nltk data manually worked ! thank @JustABeginning

gianpaj avatar Jan 30 '25 16:01 gianpaj

downloading the nltk data manually worked ! thank @JustABeginning

Roll On !

JustABeginning avatar Jan 30 '25 16:01 JustABeginning

I can confirm that manually download the NLTK data works on windows too:

Image

blackjyn avatar Feb 24 '25 05:02 blackjyn

Thank you! @kackcode, Option 2 worked for me on windows, I changed the download directory to C:\Users\me\AppData\Roaming\nltk_data. As per https://www.nltk.org/data.html for central installation, you can set the path to C:\nltk_data.

chiranjivbudhe avatar Mar 22 '25 06:03 chiranjivbudhe

Quick Fix for NLTK Module LookupError

Solution

To resolve this, download the required resource using one of the following methods:

Option 1: Terminal Command

Run this in your terminal:

python -m nltk.downloader averaged_perceptron_tagger

Option 2: In Python Script

Add this to your Python code:

import nltk nltk.download('averaged_perceptron_tagger') This will ensure the required resource is downloaded and available for use.

for others: if this doesn't work you should read the error message. For me it was to download 'averaged_perceptron_tagger_eng'.

nomppy avatar Mar 28 '25 18:03 nomppy