DrewThomasson / VoxNovel

VoxNovel: generate audiobooks giving each character a different voice actor.
MIT License
149 stars 18 forks source link

Resource wordnet not found & XTTS can only generate text with a maximum of 400 tokens #27

Closed ScratchMode closed 3 months ago

ScratchMode commented 3 months ago

Working with Windows 11 WSL I for the life of me can't figure out how to correct this error. I've reinstalled the WSL and Ubuntu and even the Windows Subsystem for Linux.

(VoxNovel) scratchmoded@WhiteArcher:~/VoxNovel$ python gui_run.py The following files are missing: coref_google_bert_uncased_L-12_H-768_A-12-v1.0.model, speaker_google_bert_uncased_L-12_H-768_A-12-v1.0.1.model, entities_google_bert_uncased_L-6_H-768_A-12-v1.0.model Downloading and extracting required files... Downloading the missing booknlp files... booknlp_models.zip: 100%|██████████████████████████████████████████████████████████| 1.03G/1.03G [00:09<00:00, 112MiB/s] Extracting required files... Deleting the zip file... Process completed successfully! Traceback (most recent call last): File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/corpus/util.py", line 84, in __load root = nltk.data.find(f"{self.subdir}/{zip_name}") File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/data.py", line 579, in find raise LookupError(resource_not_found) LookupError:


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

import nltk nltk.download('wordnet')

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

Attempted to load corpora/wordnet.zip/wordnet/

Searched in:

  • '/home/scratchmoded/nltk_data'
  • '/home/scratchmoded/miniconda/envs/VoxNovel/nltk_data'
  • '/home/scratchmoded/miniconda/envs/VoxNovel/share/nltk_data'
  • '/home/scratchmoded/miniconda/envs/VoxNovel/lib/nltk_data'
  • '/usr/share/nltk_data'
  • '/usr/local/share/nltk_data'
  • '/usr/lib/nltk_data'
  • '/usr/local/lib/nltk_data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/scratchmoded/VoxNovel/gui_run.py", line 113, in import nltk File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/init.py", line 153, in from nltk.translate import * File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/translate/init.py", line 24, in from nltk.translate.meteor_score import meteor_score as meteor File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/translate/meteor_score.py", line 14, in from nltk.stem.api import StemmerI File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/stem/init.py", line 34, in from nltk.stem.wordnet import WordNetLemmatizer File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/stem/wordnet.py", line 13, in class WordNetLemmatizer: File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/stem/wordnet.py", line 48, in WordNetLemmatizer morphy = wn.morphy File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/corpus/util.py", line 120, in getattr self.load() File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/corpus/util.py", line 86, in load raise e File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/corpus/util.py", line 81, in load root = nltk.data.find(f"{self.subdir}/{self.name}") File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/nltk/data.py", line 579, in find raise LookupError(resource_not_found) LookupError:


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

import nltk nltk.download('wordnet')

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

Attempted to load corpora/wordnet

Searched in:

  • '/home/scratchmoded/nltk_data'
  • '/home/scratchmoded/miniconda/envs/VoxNovel/nltk_data'
  • '/home/scratchmoded/miniconda/envs/VoxNovel/share/nltk_data'
  • '/home/scratchmoded/miniconda/envs/VoxNovel/lib/nltk_data'
  • '/usr/share/nltk_data'
  • '/usr/local/share/nltk_data'
  • '/usr/lib/nltk_data'
  • '/usr/local/lib/nltk_data'
DrewThomasson commented 3 months ago

Are you using the auto-installer for windows in WSL?

How are you installing it, what steps?

ScratchMode commented 3 months ago

I followed these steps

In your PowerShell, paste:

wsl --install
to install WSL. (You might be prompted by your system to enable virtualization in your BIOS if it's available, as it is needed to run WSL on Windows.)

After setting your username and password, open WSL and paste this command for a single command install:

yes | wget -O - https://raw.githubusercontent.com/DrewThomasson/VoxNovel/main/shell_install_scripts/Ubuntu-install.sh | bash
(Optional only for Nvida graphics cards Do not run this command if you don't have a Nvidia graphics card) Install the NVIDIA CUDA toolkit (required for Nvidia GPU acceleration):

sudo apt install nvidia-cuda-toolkit
Make sure you are in the VoxNovel conda environment:(If 'conda: command not found ' IE- conda is not seen as a command then try closing out of the current powershell window and relaunching the wsl env with [ wsl -d Ubuntu ]

conda activate VoxNovel
Navigate to the VoxNovel folder (if not already there):

cd ~ && cd VoxNovel
Congrats! VoxNovel should run in WSL now!
DrewThomasson commented 3 months ago

Here I'll reinstall it in wsl on my computer to see if there's a new bug from something else,

DrewThomasson commented 3 months ago

Do you think you could send me the file file your testing on it as well?

ScratchMode commented 3 months ago

The Journey to the West Volume 1.zip

DrewThomasson commented 3 months ago

Thx 👍

Status: unregistered wsl and reinstalling right now...

DrewThomasson commented 3 months ago

Good news!

It's not just your computer

Something is going on with NLTK servers with downloading the modules,

I'll try to retrieve it from one of my Voxnovel docker images, and give you a zip of all the NLTK files to put into your NLTK folder,

Along with a step by step guide of how to put it in your wsl machine

ScratchMode commented 3 months ago

Thanks Drew, I look forward to tripping over the next steps when I see them

DrewThomasson commented 3 months ago

It's not that bad lol, just copy a folder lol.

Installing NLTK in WSL Environment Manually

  1. Launch the WSL Environment

    • Open your PowerShell and run:
      wsl -d Ubuntu
  2. Access the WSL Filesystem in Windows File Explorer

    • Navigate to the following path:
      \\wsl$\Ubuntu\home\USERNAME\miniconda\envs\VoxNovel\lib\python3.10\site-packages
    • Replace USERNAME with the username you set up when configuring WSL.
  3. Replace the NLTK Files

    • Download and unzip the NLTK files nltk.zip.
    • Copy the unzipped nltk folder and paste it into the directory from step 2.
    • When prompted to replace files, select "Yes" to overwrite any existing files.
  4. Done!

    • Test the installation by going back to your WSL Ubuntu environment:
      python
    • Then, try importing NLTK:
      import nltk
    • If everything works correctly, you can now continue where you left off.

Easy Windows 11 Installation Guide for VoxNovel ### Watch the Installation Video [Watch here](https://youtu.be/OmJub3uvfz4). ### Step-by-Step Instructions 1. **Install WSL** - In PowerShell, run: ```sh wsl --install ``` - You might be prompted to enable virtualization in your BIOS if it's not already enabled. 2. **Set Up WSL** - After setting your username and password in WSL, run the following command to install everything needed for VoxNovel: ```sh yes | wget -O - https://raw.githubusercontent.com/DrewThomasson/VoxNovel/main/shell_install_scripts/Ubuntu-install.sh | bash ``` 3. **(Optional: NVIDIA Graphics Card Users Only)** - Install the NVIDIA CUDA toolkit for GPU acceleration: ```sh sudo apt install nvidia-cuda-toolkit ``` 4. **Activate the VoxNovel Conda Environment** - Make sure you're in the VoxNovel environment: ```sh conda activate VoxNovel ``` - If you see an error like `conda: command not found`, close PowerShell and relaunch WSL with: ```sh wsl -d Ubuntu ``` 5. **Navigate to the VoxNovel Folder** - If not already in the folder, run: ```sh cd ~ && cd VoxNovel ``` 6. **Congrats!** - VoxNovel should now be running in WSL. ### 🚀 To Run the Program ```sh python gui_run.py ``` ### 🚀 Or to Run Headless ```sh python headless_voxnovel.py ``` ### Troubleshooting WSL 1. **List All WSL Environments** ```sh wsl --list --verbose ``` 2. **Remove a Specific WSL Environment** ```sh wsl --unregister ``` 3. **Reinstall WSL** ```sh wsl --install ``` To launch WSL anytime, you can use the search bar in Windows to find and launch "WSL" or run: ```sh wsl ```

This format is clear and well-organized, making it easier for users to follow the steps.

DrewThomasson commented 3 months ago

Tested on my end seems to work for me

ScratchMode commented 3 months ago

Doing a fresh install to unmuck all the troubleshooting i attempted....

Success, got to the Process File GUI.

DrewThomasson commented 3 months ago

kk, also doing a test update to the Ubuntu install script so then it'll automatically do this new step I gave you lol

so no one ever has to do this again, andddd so I don't have to rely on nltk's servers anymore

that might be easier for you too lol, ill give you an update once I'm done testing this new updated auto installer

ScratchMode commented 3 months ago

Failed real fast, happen to know what this means? ❗ XTTS can only generate text with a maximum of 400 tokens.

Exception in thread Thread-3 (generate_audio): Traceback (most recent call last): File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/threading.py", line 953, in run self._target(*self._args, self._kwargs) File "/home/scratchmoded/VoxNovel/gui_run.py", line 1922, in generate_audio tts.tts_to_file(text=fragment, file_path=f"Working_files/temp/{temp_count}.wav", speaker_wav=list_reference_files(voice_actor), language=language_code) File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/TTS/api.py", line 432, in tts_to_file wav = self.tts( File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/TTS/api.py", line 364, in tts wav = self.synthesizer.tts( File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/TTS/utils/synthesizer.py", line 383, in tts outputs = self.tts_model.synthesize( File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/TTS/tts/models/xtts.py", line 397, in synthesize return self.inference_with_config(text, config, ref_audio_path=speaker_wav, language=language, kwargs) File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/TTS/tts/models/xtts.py", line 419, in inference_with_config return self.full_inference(text, ref_audio_path, language, settings) File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, *kwargs) File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/TTS/tts/models/xtts.py", line 488, in full_inference return self.inference( File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(args, kwargs) File "/home/scratchmoded/miniconda/envs/VoxNovel/lib/python3.10/site-packages/TTS/tts/models/xtts.py", line 535, in inference text_tokens.shape[-1] < self.args.gpt_max_text_tokens AssertionError: ❗ XTTS can only generate text with a maximum of 400 tokens.

DrewThomasson commented 3 months ago

yeah for some reason, It's passing in a chunk of text that is too large for XTTS to handle, lemmi look at the code I thought i fixed these issues

ScratchMode commented 3 months ago

You're the best, Drew.

ScratchMode commented 3 months ago

when I edit the book to go straight to chapter 1, it seems to be working OK. I think the error might have to due with the jumble of crap on the first few pages

ISBN: 978-0-226-97131-5 (v. 1: cloth : alkaline paper) — ISBN: 0-226-97131-7 (v. 1.: cloth : alkaline paper) — ISBN: 978-0-226-97132-2 (v. 1 : pbk. : alkaline paper) — ISBN: 0-226-97132-5 (v. 1 : pbk. : alkaline paper) — ISBN: 978-0-226-97140-7 (v. 1 : e-book) (print) — ISBN: 978-0-226-97133-9 (v. 2: cloth : alkaline paper) — ISBN: 0-226-97133-3 (v. 2 : cloth : alkaline paper) — ISBN: 978-0-226-97134-6 (v. 2 : paperback : alkaline paper) — ISBN: 0-226-97134-1 (v. 2 : paperback: alkaline paper) — ISBN: 978-0-226-97141-4 (v. 2 : e-book) (print) — ISBN: 978-0-226-97136-0 (v. 3: cloth : alkaline paper) — ISBN: 0-226-97136-8 (v. 3 : cloth : alkaline paper) — ISBN: 978-0-226-97137-7 (v. 3 : paperback : alkaline paper) — ISBN: 0-226-97137-6 (v. 3 : paperback : alkaline paper) — ISBN: 978-0-226-97142-1 (v. 3 : e-book) (print) — ISBN: 978-0-226-97138-4 (v. 4 : cloth : alkaline paper) — ISBN: 0-226-97138-4 (v. 4 : cloth : alkaline paper) — ISBN: 978-0-226-97139-1 (v. 4 : paperback : alkaline paper) — ISBN: 978-0-226-97143-8 (v. 4 : e-book) 1. Xuanzang, ca. 596–664—Fiction. I. Yu, Anthony C., 1938–, translator, editor. II. Title.

PL2697.H75E5 2012

895.1'346—dc23

DrewThomasson commented 3 months ago

kk here go into the VoxNovel folder, run

git pull

thatll update your VoxNovel folder

then try running

test.py

That's a test script with my new modification, see if that works

DrewThomasson commented 3 months ago

Yeah, that usually Causes the issues lol, I have it split by sentences, and i guess all of the stuff at the beginning counts as a single sentence lol

DrewThomasson commented 3 months ago

when I edit the book to go straight to chapter 1, it seems to be working OK. I think the error might have to due with the jumble of crap on the first few pages

ISBN: 978-0-226-97131-5 (v. 1: cloth : alkaline paper) — ISBN: 0-226-97131-7 (v. 1.: cloth : alkaline paper) — ISBN: 978-0-226-97132-2 (v. 1 : pbk. : alkaline paper) — ISBN: 0-226-97132-5 (v. 1 : pbk. : alkaline paper) — ISBN: 978-0-226-97140-7 (v. 1 : e-book) (print) — ISBN: 978-0-226-97133-9 (v. 2: cloth : alkaline paper) — ISBN: 0-226-97133-3 (v. 2 : cloth : alkaline paper) — ISBN: 978-0-226-97134-6 (v. 2 : paperback : alkaline paper) — ISBN: 0-226-97134-1 (v. 2 : paperback: alkaline paper) — ISBN: 978-0-226-97141-4 (v. 2 : e-book) (print) — ISBN: 978-0-226-97136-0 (v. 3: cloth : alkaline paper) — ISBN: 0-226-97136-8 (v. 3 : cloth : alkaline paper) — ISBN: 978-0-226-97137-7 (v. 3 : paperback : alkaline paper) — ISBN: 0-226-97137-6 (v. 3 : paperback : alkaline paper) — ISBN: 978-0-226-97142-1 (v. 3 : e-book) (print) — ISBN: 978-0-226-97138-4 (v. 4 : cloth : alkaline paper) — ISBN: 0-226-97138-4 (v. 4 : cloth : alkaline paper) — ISBN: 978-0-226-97139-1 (v. 4 : paperback : alkaline paper) — ISBN: 978-0-226-97143-8 (v. 4 : e-book) 1. Xuanzang, ca. 596–664—Fiction. I. Yu, Anthony C., 1938–, translator, editor. II. Title. PL2697.H75E5 2012 895.1'346—dc23

Good to hear that that worked for you! Yeah the sentence splitter function works for run, on sentences but not for stuff like that lol, hit me up if you run into any other issues tho

DrewThomasson commented 3 months ago

@ScratchMode

FIX UPDATE:

Changed max_length=230 to max_length=220 for the sentence splitter function,

This fixed it on my end, I was able to get your ebook you gave me working without having to take out the beginning of the ebook.

Happy Audiobook generating! :)