Closed ROBERT-MCDOWELL closed 2 weeks ago
## Replace
nltk.download('punkt_tab')
## With
nltk.download('punkt')
Just run this command in your terminal lol
python -m nltk.downloader punkt
Or you could just run the docker
Then you won't have any issues lol
Did it fix it?
I'm running the docker indeed. so I cannot use the command above :(
but wait, how to use the command line with the docker? I don't want to use the GUI as my server is headless. I think I must learn more about docker.
oh hm, actually good point,
I'll, put all of the GitHub repo files into the docker image and come back to you with a modified docker launch command for headless
ok I cleaned up completely docker and restart to install your docker but now I get starting... [nltk_data] Error loading punkt_tab: <urlopen error [Errno -3] [nltk_data] Temporary failure in name resolution> Traceback (most recent call last): File "/usr/local/lib/python3.10/urllib/request.py", line 1348, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/usr/local/lib/python3.10/http/client.py", line 1283, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1329, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1278, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1038, in _send_output self.send(msg) File "/usr/local/lib/python3.10/http/client.py", line 976, in send self.connect() File "/usr/local/lib/python3.10/http/client.py", line 1448, in connect super().connect() File "/usr/local/lib/python3.10/http/client.py", line 942, in connect self.sock = self._create_connection( File "/usr/local/lib/python3.10/socket.py", line 836, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/usr/local/lib/python3.10/socket.py", line 967, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/app/app.py", line 30, in
We will mount the ebook2audiobookXTTS/
folder from your local machine to the Docker container, so the app can access any input files (e.g., EPUB files) placed in that folder.
Hereβs the full Docker command to achieve this:
<path_to_ebook_file> [path_to_voice_file] [language_code]
will be in reference to the
ebook2audiobookXTTS
folder so like the epub will be ebook2audiobookXTTS/epub-file.epub
docker run -it --rm -p 7860:7860 --platform=linux/amd64 --pull always -v /path/to/local/ebook2audiobookXTTS:/app/ebook2audiobookXTTS registry.hf.space/drewthomasson-ebook2audiobookxtts:latest python /app/ebook2audiobookXTTS/ebook2audiobook.py ebook2audiobook.py <path_to_ebook_file> [path_to_voice_file] [language_code]
Explanation of the Command:
-it: Runs the container interactively.
--rm: Automatically removes the container after it exits.
-p 7860:7860: Exposes port 7860 so you can access the Gradio interface or any other services.
--platform=linux/amd64: Ensures compatibility with the amd64 architecture.
--pull always: Ensures the latest version of the Docker image is pulled each time.
-v /path/to/local/ebook2audiobookXTTS:/app/ebook2audiobookXTTS: Mounts the local ebook2audiobookXTTS/ folder to the container, allowing access to the app and input files. registry.hf.space/drewthomasson-ebook2audiobookxtts:latest: Specifies the Docker image to use.
python /app/ebook2audiobookXTTS/ebook2audiobook.py : Runs the specified Python app within the container
I will have a tested and working implementation of this before the end of today though.
ok I cleaned up completely docker and restart to install your docker but now I get starting... [nltk_data] Error loading punkt_tab: <urlopen error [Errno -3] [nltk_data] Temporary failure in name resolution> Traceback (most recent call last): File "/usr/local/lib/python3.10/urllib/request.py", line 1348, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/usr/local/lib/python3.10/http/client.py", line 1283, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1329, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1278, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1038, in _send_output self.send(msg) File "/usr/local/lib/python3.10/http/client.py", line 976, in send self.connect() File "/usr/local/lib/python3.10/http/client.py", line 1448, in connect super().connect() File "/usr/local/lib/python3.10/http/client.py", line 942, in connect self.sock = self._create_connection( File "/usr/local/lib/python3.10/socket.py", line 836, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/usr/local/lib/python3.10/socket.py", line 967, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/user/app/app.py", line 30, in import download_tos_agreed_file File "/home/user/app/download_tos_agreed_file.py", line 23, in download_tos_agreed() File "/home/user/app/download_tos_agreed_file.py", line 17, in download_tos_agreed urllib.request.urlretrieve(file_url, file_path) File "/usr/local/lib/python3.10/urllib/request.py", line 241, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "/usr/local/lib/python3.10/urllib/request.py", line 216, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python3.10/urllib/request.py", line 519, in open response = self._open(req, data) File "/usr/local/lib/python3.10/urllib/request.py", line 536, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "/usr/local/lib/python3.10/urllib/request.py", line 496, in _call_chain result = func(*args) File "/usr/local/lib/python3.10/urllib/request.py", line 1391, in https_open return self.do_open(http.client.HTTPSConnection, req, File "/usr/local/lib/python3.10/urllib/request.py", line 1351, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
oh and I didnt forget about this, hm
what was your full docker run command for it?
oh I see.... I'll get the docker image to be easily runnable in a public manner as well
the command was docker run -it --rm -p 7860:7860 --platform=linux/amd64 athomasson2/ebook2audiobookxtts:huggingface python app.py
then tried the one above
docker run -it --rm -p 7860:7860 --platform=linux/amd64 --pull always -v /path/to/local/ebook2audiobookXTTS:/app/ebook2audiobookXTTS registry.hf.space/drewthomasson-ebook2audiobookxtts:latest python /app/ebook2audiobookXTTS/ebook2audiobook.py ebook2audiobook.py
gives
latest: Pulling from drewthomasson-ebook2audiobookxtts
eaa6071ac135: Pull complete
4887aa1af7bc: Pull complete
2fe776c703b1: Pull complete
e9ca11e1d57b: Pull complete
8b352e63b19a: Pull complete
d5f6fa00f923: Pull complete
ea8411a744a3: Pull complete
9e788e27f6ff: Pull complete
806a30b761f2: Pull complete
Digest: sha256:0eb4f626af8442ccd4086694522768597d0f571c1e3fbcfcbb570ea61715e720
Status: Downloaded newer image for registry.hf.space/drewthomasson-ebook2audiobookxtts:latest
starting...
[nltk_data] Error loading punkt: <urlopen error [Errno -3] Temporary
[nltk_data] failure in name resolution>
Wiping and removeing Working_files folder...
Error removing ./Working_files: [Errno 2] No such file or directory: './Working_files'
Wiping and and removeing chapter_wav_files folder...
Error removing ./Chapter_wav_files: [Errno 2] No such file or directory: './Chapter_wav_files'
Created directory: ./Working_files/Book
The file ./Working_files/temp.epub does not exist.
Cannot read from /home/user/app/ebook2audiobook.py
An error occurred while converting the eBook: Command '['ebook-convert', 'ebook2audiobook.py', './Working_files/temp.epub']' returned non-zero exit status 1.
[nltk_data] Error loading punkt: <urlopen error [Errno -3] Temporary
[nltk_data] failure in name resolution>
Traceback (most recent call last):
File "/app/ebook2audiobookXTTS/ebook2audiobook.py", line 458, in
I'll get back to you when I have a tested and working version on my computer that doesn't rly on the gradio interface
btw what are you running this headless env on anyway?
Ubuntu? Windows? Mac? Arch linux? Fedora?
Linux Fedora 40
Still working on it lol
About to drop a new and improved version that does all of the other scripts functionality in a docker offline lol
first for a docker pull of the latest with
docker pull registry.hf.space/drewthomasson-ebook2audiobookxtts:latest
Before you do run this you need to create a dir named "input-folder" in your current dir which will be linked, This is where you can put your input files for the docker image to see
mkdir input-folder && mkdir Audiobooks
In the command below swap out YOUR_INPUT_FILE.TXT with the name of your input file
docker run -it --rm \
-v $(pwd)/input-folder:/home/user/app/input_folder \
-v $(pwd)/Audiobooks:/home/user/app/Audiobooks \
--platform linux/amd64 \
registry.hf.space/drewthomasson-ebook2audiobookxtts:latest \
python app.py --headless True --ebook /home/user/app/input_folder/YOUR_INPUT_FILE.TXT
And that should be it!
The output Audiobooks will be found in the Audiobook folder which will also be located in your local dir you ran this docker command in
docker run -it --rm \
--platform linux/amd64 \
registry.hf.space/drewthomasson-ebook2audiobookxtts:latest \
python app.py -h
and that will output this
user/app/ebook2audiobookXTTS/input-folder -v $(pwd)/Audiobooks:/home/user/app/ebook2audiobookXTTS/Audiobooks --memory="4g" --network none --platform linux/amd64 registry.hf.space/drewthomasson-ebook2audiobookxtts:latest python app.py -h
starting...
usage: app.py [-h] [--share SHARE] [--headless HEADLESS] [--ebook EBOOK] [--voice VOICE]
[--language LANGUAGE] [--use_custom_model USE_CUSTOM_MODEL]
[--custom_model CUSTOM_MODEL] [--custom_config CUSTOM_CONFIG]
[--custom_vocab CUSTOM_VOCAB] [--custom_model_url CUSTOM_MODEL_URL]
Convert eBooks to Audiobooks using a Text-to-Speech model. You can either launch the
Gradio interface or run the script in headless mode for direct conversion.
options:
-h, --help show this help message and exit
--share SHARE Set to True to enable a public shareable Gradio link. Defaults
to False.
--headless HEADLESS Set to True to run in headless mode without the Gradio
interface. Defaults to False.
--ebook EBOOK Path to the ebook file for conversion. Required in headless
mode.
--voice VOICE Path to the target voice file for TTS. Optional, uses a default
voice if not provided.
--language LANGUAGE Language for the audiobook conversion. Options: en, es, fr, de,
it, pt, pl, tr, ru, nl, cs, ar, zh-cn, ja, hu, ko. Defaults to
English (en).
--use_custom_model USE_CUSTOM_MODEL
Set to True to use a custom TTS model. Defaults to False. Must
be True to use custom models, otherwise you'll get an error.
--custom_model CUSTOM_MODEL
Path to the custom model file (.pth). Required if using a custom
model.
--custom_config CUSTOM_CONFIG
Path to the custom config file (config.json). Required if using
a custom model.
--custom_vocab CUSTOM_VOCAB
Path to the custom vocab file (vocab.json). Required if using a
custom model.
--custom_model_url CUSTOM_MODEL_URL
URL to download the custom model as a zip file. Optional, but
will be used if provided. Examples include David Attenborough's
model: 'https://huggingface.co/drewThomasson/xtts_David_Attenbor
ough_fine_tune/resolve/main/Finished_model_files.zip?download=tr
ue'. More XTTS fine-tunes can be found on my Hugging Face at
'https://huggingface.co/drewThomasson'.
Example: python script.py --headless --ebook path_to_ebook --voice path_to_voice
--language en --use_custom_model True --custom_model model.pth --custom_config
config.json --custom_vocab vocab.json
bon appetit
ok I will give a try as soon as I have a time ;) btw why $(pwd)?
It's just makes it easier on you lol
Then it creates the folder at the working directory for you instead of you having to type out the full path
You can use the full path if you want too though
oops, I mixed pwd with passwd :-\
Seems to work :D! it needs a little time as my server is on CPU and will give you the final report. I will certainly try to install it on a virtual env. However I have some suggestions:
keep it going, your project is becoming pretty nice!
Those are good suggestions ngl lol
I'll look at adding them
I'm also looking at doing another update that'll potentially allow you to change the generation speed and such of Xtts,
Also the program should automatically grab onto the nearest CUDA capable device it sees, and if not it'll just use CPU
yup, that's a good option too indeed. I noticed also during the log process that the total remaining segments is not visible so we cannot have a time estimation or the remaining segments to convert.... forget NPU, it's too new and btw I really don't like what they (the device makers) want to do with.... akind of super spy. Also did you think about crashes or unwanted end of the process so have a way to resume what's already converted?
I don't have a resume or pause feature at the moment sadly lol
That's also up there on the list lol
The Best I can do right now is point to how to pause or resume a docker image lol
https://github.com/DrewThomasson/VoxNovel/issues/21#issuecomment-2366910480
is each segment = one audio file?, or does it go to into one global file? or the RAM until it's finished?
Each segment in the code is processed separately into individual audio files (fragments)
Here's a short summary of how the process works:
Chapter Processing:
Fragment Generation:
.wav
file in a "temp" directory. This avoids loading everything into RAM at once, which helps with memory management.Combining Audio:
audio_chapter_1.wav
).Final M4B Audiobook:
ffmpeg
.So, each fragment gets saved as an individual audio file, combined into chapter audio files, and ultimately merged into a single audiobook file at the end.
good, so it should be easy on resume to check what are already done and jump to the next segment....
lol yup
--device ["gpu","cpu"] added if params does not exists or if params is gpu but no gpu avaliable so it will be "cpu" I made also some more tolerant params behavior concerning --headless and --custom*, I will do a full explanation of the changes once the PR will be done. btw, if you think the PR will be too shocking for you (I mean all the code refactored) so maybe I can create a fresh new repo and work in parallel with your repo without to disturb your habits....
Nice
/home/src/AI/ebook2audiobookXTTS/env_py311/lib64/python3.11/site-packages/torch/cuda/init.py:654: UserWarning: Can't initialize NVML warnings.warn("Can't initialize NVML")
For more information see: https://www.nltk.org/data.html
Attempted to load tokenizers/punkt_tab/english/
Searched in:
any idea how to solve it?