ebook2audiobook 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ebook2audiobook-0.0.1/LICENSE +21 -0
- ebook2audiobook-0.0.1/PKG-INFO +14 -0
- ebook2audiobook-0.0.1/README.md +477 -0
- ebook2audiobook-0.0.1/ebook2audiobook.egg-info/PKG-INFO +14 -0
- ebook2audiobook-0.0.1/ebook2audiobook.egg-info/SOURCES.txt +9 -0
- ebook2audiobook-0.0.1/ebook2audiobook.egg-info/dependency_links.txt +1 -0
- ebook2audiobook-0.0.1/ebook2audiobook.egg-info/entry_points.txt +2 -0
- ebook2audiobook-0.0.1/ebook2audiobook.egg-info/requires.txt +7 -0
- ebook2audiobook-0.0.1/ebook2audiobook.egg-info/top_level.txt +1 -0
- ebook2audiobook-0.0.1/setup.cfg +4 -0
- ebook2audiobook-0.0.1/setup.py +51 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Drew Thomasson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ebook2audiobook
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A package to convert ebooks to audiobooks
|
|
5
|
+
Author: Andrew Phillip Thomasson
|
|
6
|
+
Author-email: drew.thomasson100@gmail.com
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: coqui-tts==0.24.2
|
|
9
|
+
Requires-Dist: pydub
|
|
10
|
+
Requires-Dist: nltk
|
|
11
|
+
Requires-Dist: beautifulsoup4
|
|
12
|
+
Requires-Dist: ebooklib
|
|
13
|
+
Requires-Dist: tqdm
|
|
14
|
+
Requires-Dist: gradio==4.44.0
|
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
# đ ebook2audiobook
|
|
2
|
+
|
|
3
|
+
Convert eBooks to audiobooks with chapters and metadata using Calibre and Coqui XTTS. Supports optional voice cloning and multiple languages!
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#### đĨī¸ Web GUI Interface
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
<details>
|
|
10
|
+
<summary>Click to see images of Web GUI</summary>
|
|
11
|
+
<img width="1728" alt="image" src="https://github.com/user-attachments/assets/b36c71cf-8e06-484c-a252-934e6b1d0c2f">
|
|
12
|
+
<img width="1728" alt="image" src="https://github.com/user-attachments/assets/c0dab57a-d2d4-4658-bff9-3842ec90cb40">
|
|
13
|
+
<img width="1728" alt="image" src="https://github.com/user-attachments/assets/0a99eeac-c521-4b21-8656-e064c1adc528">
|
|
14
|
+
</details>
|
|
15
|
+
|
|
16
|
+
## README.md
|
|
17
|
+
- en [English](README.md)
|
|
18
|
+
- zh_CN [įŽäŊ䏿](readme/README_CN.md)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## đ Features
|
|
22
|
+
|
|
23
|
+
- đ Converts eBooks to text format with Calibre.
|
|
24
|
+
- đ Splits eBook into chapters for organized audio.
|
|
25
|
+
- đī¸ High-quality text-to-speech with Coqui XTTS.
|
|
26
|
+
- đŖī¸ Optional voice cloning with your own voice file.
|
|
27
|
+
- đ Supports multiple languages (English by default).
|
|
28
|
+
- đĨī¸ Designed to run on 4GB RAM.
|
|
29
|
+
|
|
30
|
+
## đ¤ [Huggingface space demo](https://huggingface.co/spaces/drewThomasson/ebook2audiobookXTTS)
|
|
31
|
+
- Huggingface space is running on free cpu tier so expect very slow or timeout lol, just don't give it giant files is all
|
|
32
|
+
- Best to duplicate space or run locally.
|
|
33
|
+
|
|
34
|
+
## Free Google Colab [](https://colab.research.google.com/github/DrewThomasson/ebook2audiobookXTTS/blob/main/Notebooks/colab_ebook2audiobookxtts.ipynb)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## đ ī¸ Requirements
|
|
38
|
+
|
|
39
|
+
- Python 3.10
|
|
40
|
+
- `coqui-tts` Python package
|
|
41
|
+
- Calibre (for eBook conversion)
|
|
42
|
+
- FFmpeg (for audiobook creation)
|
|
43
|
+
- Optional: Custom voice file for voice cloning
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### đ§ Installation Instructions
|
|
47
|
+
|
|
48
|
+
1. **Install Python 3.x** from [Python.org](https://www.python.org/downloads/).
|
|
49
|
+
|
|
50
|
+
2. **Install Calibre**:
|
|
51
|
+
- **Ubuntu**: `sudo apt-get install -y calibre`
|
|
52
|
+
- **macOS**: `brew install calibre`
|
|
53
|
+
- **Windows** (Admin Powershell): `choco install calibre`
|
|
54
|
+
|
|
55
|
+
3. **Install FFmpeg**:
|
|
56
|
+
- **Ubuntu**: `sudo apt-get install -y ffmpeg`
|
|
57
|
+
- **macOS**: `brew install ffmpeg`
|
|
58
|
+
- **Windows** (Admin Powershell): `choco install ffmpeg`
|
|
59
|
+
|
|
60
|
+
4. **Optional: Install Mecab** (for non-Latin languages):
|
|
61
|
+
- **Ubuntu**: `sudo apt-get install -y mecab libmecab-dev mecab-ipadic-utf8`
|
|
62
|
+
- **macOS**: `brew install mecab`, `brew install mecab-ipadic`
|
|
63
|
+
- **Windows**: [mecab-website-to-install-manually](https://taku910.github.io/mecab/#download) (Note: Japanese support is limited)
|
|
64
|
+
|
|
65
|
+
5. **Install Python packages**:
|
|
66
|
+
```bash
|
|
67
|
+
pip install coqui-tts==0.24.2 pydub nltk beautifulsoup4 ebooklib tqdm gradio==4.44.0
|
|
68
|
+
|
|
69
|
+
python -m nltk.downloader punkt
|
|
70
|
+
python -m nltk.downloader punkt_tab
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**For non-Latin languages**:
|
|
74
|
+
```bash
|
|
75
|
+
pip install mecab mecab-python3 unidic
|
|
76
|
+
|
|
77
|
+
python -m unidic download
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## đ Supported Languages
|
|
81
|
+
|
|
82
|
+
- **English (en)**
|
|
83
|
+
- **Spanish (es)**
|
|
84
|
+
- **French (fr)**
|
|
85
|
+
- **German (de)**
|
|
86
|
+
- **Italian (it)**
|
|
87
|
+
- **Portuguese (pt)**
|
|
88
|
+
- **Polish (pl)**
|
|
89
|
+
- **Turkish (tr)**
|
|
90
|
+
- **Russian (ru)**
|
|
91
|
+
- **Dutch (nl)**
|
|
92
|
+
- **Czech (cs)**
|
|
93
|
+
- **Arabic (ar)**
|
|
94
|
+
- **Chinese (zh-cn)**
|
|
95
|
+
- **Japanese (ja)**
|
|
96
|
+
- **Hungarian (hu)**
|
|
97
|
+
- **Korean (ko)**
|
|
98
|
+
|
|
99
|
+
Specify the language code when running the script in headless mode.
|
|
100
|
+
## đ Usage
|
|
101
|
+
|
|
102
|
+
### đĨī¸ Launching Gradio Web Interface
|
|
103
|
+
|
|
104
|
+
1. **Run the Script**:
|
|
105
|
+
```bash
|
|
106
|
+
python app.py
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
2. **Open the Web App**: Click the URL provided in the terminal to access the web app and convert eBooks.
|
|
110
|
+
3. **For Public Link**: Add `--share True` to the end of it like this: `python app.py --share True`
|
|
111
|
+
- **[For More Parameters]**: use the `-h` parameter like this `python app.py -h`
|
|
112
|
+
|
|
113
|
+
### đ Basic Headless Usage
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
python app.py --headless True --ebook <path_to_ebook_file> --voice [path_to_voice_file] --language [language_code]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
- **<path_to_ebook_file>**: Path to your eBook file.
|
|
120
|
+
- **[path_to_voice_file]**: Optional for voice cloning.
|
|
121
|
+
- **[language_code]**: Optional to specify language.
|
|
122
|
+
- **[For More Parameters]**: use the `-h` parameter like this `python app.py -h`
|
|
123
|
+
|
|
124
|
+
### đ§Š Headless Custom XTTS Model Usage
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
python app.py --headless True --use_custom_model True --ebook <ebook_file_path> --voice <target_voice_file_path> --language <language> --custom_model <custom_model_path> --custom_config <custom_config_path> --custom_vocab <custom_vocab_path>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- **<ebook_file_path>**: Path to your eBook file.
|
|
131
|
+
- **<target_voice_file_path>**: Optional for voice cloning.
|
|
132
|
+
- **<language>**: Optional to specify language.
|
|
133
|
+
- **<custom_model_path>**: Path to `model.pth`.
|
|
134
|
+
- **<custom_config_path>**: Path to `config.json`.
|
|
135
|
+
- **<custom_vocab_path>**: Path to `vocab.json`.
|
|
136
|
+
- **[For More Parameters]**: use the `-h` parameter like this `python app.py -h`
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
### đ§Š Headless Custom XTTS Model Usage With Zip link to XTTS Fine-Tune Model đ
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
python app.py --headless True --use_custom_model True --ebook <ebook_file_path> --voice <target_voice_file_path> --language <language> --custom_model_url <custom_model_URL_ZIP_path>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- **<ebook_file_path>**: Path to your eBook file.
|
|
146
|
+
- **<target_voice_file_path>**: Optional for voice cloning.
|
|
147
|
+
- **<language>**: Optional to specify language.
|
|
148
|
+
- **<custom_model_URL_ZIP_path>**: URL Path to zip of Model folder. For Example this for the [xtts_David_Attenborough_fine_tune](https://huggingface.co/drewThomasson/xtts_David_Attenborough_fine_tune/tree/main) `https://huggingface.co/drewThomasson/xtts_David_Attenborough_fine_tune/resolve/main/Finished_model_files.zip?download=true`
|
|
149
|
+
- For a custom model a ref audio clip of the voice will also be needed:
|
|
150
|
+
[ref audio clip of David Attenborough](https://huggingface.co/drewThomasson/xtts_David_Attenborough_fine_tune/blob/main/ref.wav)
|
|
151
|
+
- **[For More Parameters]**: use the `-h` parameter like this `python app.py -h`
|
|
152
|
+
|
|
153
|
+
### đ For Detailed Guide with list of all Parameters to use
|
|
154
|
+
```bash
|
|
155
|
+
python app.py -h
|
|
156
|
+
```
|
|
157
|
+
- This will output the following:
|
|
158
|
+
```bash
|
|
159
|
+
usage: app.py [-h] [--share SHARE] [--headless HEADLESS] [--ebook EBOOK] [--voice VOICE]
|
|
160
|
+
[--language LANGUAGE] [--use_custom_model USE_CUSTOM_MODEL]
|
|
161
|
+
[--custom_model CUSTOM_MODEL] [--custom_config CUSTOM_CONFIG]
|
|
162
|
+
[--custom_vocab CUSTOM_VOCAB] [--custom_model_url CUSTOM_MODEL_URL]
|
|
163
|
+
[--temperature TEMPERATURE] [--length_penalty LENGTH_PENALTY]
|
|
164
|
+
[--repetition_penalty REPETITION_PENALTY] [--top_k TOP_K] [--top_p TOP_P]
|
|
165
|
+
[--speed SPEED] [--enable_text_splitting ENABLE_TEXT_SPLITTING]
|
|
166
|
+
|
|
167
|
+
Convert eBooks to Audiobooks using a Text-to-Speech model. You can either launch the
|
|
168
|
+
Gradio interface or run the script in headless mode for direct conversion.
|
|
169
|
+
|
|
170
|
+
options:
|
|
171
|
+
-h, --help show this help message and exit
|
|
172
|
+
--share SHARE Set to True to enable a public shareable Gradio link. Defaults
|
|
173
|
+
to False.
|
|
174
|
+
--headless HEADLESS Set to True to run in headless mode without the Gradio
|
|
175
|
+
interface. Defaults to False.
|
|
176
|
+
--ebook EBOOK Path to the ebook file for conversion. Required in headless
|
|
177
|
+
mode.
|
|
178
|
+
--voice VOICE Path to the target voice file for TTS. Optional, uses a default
|
|
179
|
+
voice if not provided.
|
|
180
|
+
--language LANGUAGE Language for the audiobook conversion. Options: en, es, fr, de,
|
|
181
|
+
it, pt, pl, tr, ru, nl, cs, ar, zh-cn, ja, hu, ko. Defaults to
|
|
182
|
+
English (en).
|
|
183
|
+
--use_custom_model USE_CUSTOM_MODEL
|
|
184
|
+
Set to True to use a custom TTS model. Defaults to False. Must
|
|
185
|
+
be True to use custom models, otherwise you'll get an error.
|
|
186
|
+
--custom_model CUSTOM_MODEL
|
|
187
|
+
Path to the custom model file (.pth). Required if using a custom
|
|
188
|
+
model.
|
|
189
|
+
--custom_config CUSTOM_CONFIG
|
|
190
|
+
Path to the custom config file (config.json). Required if using
|
|
191
|
+
a custom model.
|
|
192
|
+
--custom_vocab CUSTOM_VOCAB
|
|
193
|
+
Path to the custom vocab file (vocab.json). Required if using a
|
|
194
|
+
custom model.
|
|
195
|
+
--custom_model_url CUSTOM_MODEL_URL
|
|
196
|
+
URL to download the custom model as a zip file. Optional, but
|
|
197
|
+
will be used if provided. Examples include David Attenborough's
|
|
198
|
+
model: 'https://huggingface.co/drewThomasson/xtts_David_Attenbor
|
|
199
|
+
ough_fine_tune/resolve/main/Finished_model_files.zip?download=tr
|
|
200
|
+
ue'. More XTTS fine-tunes can be found on my Hugging Face at
|
|
201
|
+
'https://huggingface.co/drewThomasson'.
|
|
202
|
+
--temperature TEMPERATURE
|
|
203
|
+
Temperature for the model. Defaults to 0.65. Higher Tempatures
|
|
204
|
+
will lead to more creative outputs IE: more Hallucinations.
|
|
205
|
+
Lower Tempatures will be more monotone outputs IE: less
|
|
206
|
+
Hallucinations.
|
|
207
|
+
--length_penalty LENGTH_PENALTY
|
|
208
|
+
A length penalty applied to the autoregressive decoder. Defaults
|
|
209
|
+
to 1.0. Not applied to custom models.
|
|
210
|
+
--repetition_penalty REPETITION_PENALTY
|
|
211
|
+
A penalty that prevents the autoregressive decoder from
|
|
212
|
+
repeating itself. Defaults to 2.0.
|
|
213
|
+
--top_k TOP_K Top-k sampling. Lower values mean more likely outputs and
|
|
214
|
+
increased audio generation speed. Defaults to 50.
|
|
215
|
+
--top_p TOP_P Top-p sampling. Lower values mean more likely outputs and
|
|
216
|
+
increased audio generation speed. Defaults to 0.8.
|
|
217
|
+
--speed SPEED Speed factor for the speech generation. IE: How fast the
|
|
218
|
+
Narrerator will speak. Defaults to 1.0.
|
|
219
|
+
--enable_text_splitting ENABLE_TEXT_SPLITTING
|
|
220
|
+
Enable splitting text into sentences. Defaults to True.
|
|
221
|
+
|
|
222
|
+
Example: python script.py --headless --ebook path_to_ebook --voice path_to_voice
|
|
223
|
+
--language en --use_custom_model True --custom_model model.pth --custom_config
|
|
224
|
+
config.json --custom_vocab vocab.json
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
<details>
|
|
229
|
+
<summary>â ī¸ Legacy-Depricated Old Use Instructions</summary>
|
|
230
|
+
|
|
231
|
+
## đ Usage
|
|
232
|
+
|
|
233
|
+
## Legacy files have been moved to `ebook2audiobookXTTS/legacy/`
|
|
234
|
+
|
|
235
|
+
### đĨī¸ Gradio Web Interface
|
|
236
|
+
|
|
237
|
+
1. **Run the Script**:
|
|
238
|
+
```bash
|
|
239
|
+
python custom_model_ebook2audiobookXTTS_gradio.py
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
2. **Open the Web App**: Click the URL provided in the terminal to access the web app and convert eBooks.
|
|
243
|
+
|
|
244
|
+
### đ Basic Usage
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
python ebook2audiobook.py <path_to_ebook_file> [path_to_voice_file] [language_code]
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- **<path_to_ebook_file>**: Path to your eBook file.
|
|
251
|
+
- **[path_to_voice_file]**: Optional for voice cloning.
|
|
252
|
+
- **[language_code]**: Optional to specify language.
|
|
253
|
+
|
|
254
|
+
### đ§Š Custom XTTS Model
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
python custom_model_ebook2audiobookXTTS.py <ebook_file_path> <target_voice_file_path> <language> <custom_model_path> <custom_config_path> <custom_vocab_path>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
- **<ebook_file_path>**: Path to your eBook file.
|
|
261
|
+
- **<target_voice_file_path>**: Optional for voice cloning.
|
|
262
|
+
- **<language>**: Optional to specify language.
|
|
263
|
+
- **<custom_model_path>**: Path to `model.pth`.
|
|
264
|
+
- **<custom_config_path>**: Path to `config.json`.
|
|
265
|
+
- **<custom_vocab_path>**: Path to `vocab.json`.
|
|
266
|
+
</details>
|
|
267
|
+
|
|
268
|
+
### đŗ Using Docker
|
|
269
|
+
|
|
270
|
+
You can also use Docker to run the eBook to Audiobook converter. This method ensures consistency across different environments and simplifies setup.
|
|
271
|
+
|
|
272
|
+
#### đ Running the Docker Container
|
|
273
|
+
|
|
274
|
+
To run the Docker container and start the Gradio interface, use the following command:
|
|
275
|
+
|
|
276
|
+
-Run with CPU only
|
|
277
|
+
```powershell
|
|
278
|
+
docker run -it --rm -p 7860:7860 --platform=linux/amd64 athomasson2/ebook2audiobookxtts:huggingface python app.py
|
|
279
|
+
```
|
|
280
|
+
-Run with GPU Speedup (Nvida graphics cards only)
|
|
281
|
+
```powershell
|
|
282
|
+
docker run -it --rm --gpus all -p 7860:7860 --platform=linux/amd64 athomasson2/ebook2audiobookxtts:huggingface python app.py
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
This command will start the Gradio interface on port 7860.(localhost:7860)
|
|
286
|
+
- For more options like running the docker in headless mode or making the gradio link public add the `-h` parameter after the `app.py` in the docker launch command
|
|
287
|
+
<details>
|
|
288
|
+
<summary><strong>Example of using docker in headless mode or modifying anything with the extra parameters + Full guide</strong></summary>
|
|
289
|
+
|
|
290
|
+
## Example of using docker in headless mode
|
|
291
|
+
|
|
292
|
+
first for a docker pull of the latest with
|
|
293
|
+
```bash
|
|
294
|
+
docker pull athomasson2/ebook2audiobookxtts:huggingface
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
- 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
|
|
298
|
+
```bash
|
|
299
|
+
mkdir input-folder && mkdir Audiobooks
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
- In the command below swap out **YOUR_INPUT_FILE.TXT** with the name of your input file
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
docker run -it --rm \
|
|
306
|
+
-v $(pwd)/input-folder:/home/user/app/input_folder \
|
|
307
|
+
-v $(pwd)/Audiobooks:/home/user/app/Audiobooks \
|
|
308
|
+
--platform linux/amd64 \
|
|
309
|
+
athomasson2/ebook2audiobookxtts:huggingface \
|
|
310
|
+
python app.py --headless True --ebook /home/user/app/input_folder/YOUR_INPUT_FILE.TXT
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
- And that should be it!
|
|
314
|
+
|
|
315
|
+
- 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
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
## To get the help command for the other parameters this program has you can run this
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
docker run -it --rm \
|
|
322
|
+
--platform linux/amd64 \
|
|
323
|
+
athomasson2/ebook2audiobookxtts:huggingface \
|
|
324
|
+
python app.py -h
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
and that will output this
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
user/app/ebook2audiobookXTTS/input-folder -v $(pwd)/Audiobooks:/home/user/app/ebook2audiobookXTTS/Audiobooks --memory="4g" --network none --platform linux/amd64 athomasson2/ebook2audiobookxtts:huggingface python app.py -h
|
|
333
|
+
starting...
|
|
334
|
+
usage: app.py [-h] [--share SHARE] [--headless HEADLESS] [--ebook EBOOK] [--voice VOICE]
|
|
335
|
+
[--language LANGUAGE] [--use_custom_model USE_CUSTOM_MODEL]
|
|
336
|
+
[--custom_model CUSTOM_MODEL] [--custom_config CUSTOM_CONFIG]
|
|
337
|
+
[--custom_vocab CUSTOM_VOCAB] [--custom_model_url CUSTOM_MODEL_URL]
|
|
338
|
+
[--temperature TEMPERATURE] [--length_penalty LENGTH_PENALTY]
|
|
339
|
+
[--repetition_penalty REPETITION_PENALTY] [--top_k TOP_K] [--top_p TOP_P]
|
|
340
|
+
[--speed SPEED] [--enable_text_splitting ENABLE_TEXT_SPLITTING]
|
|
341
|
+
|
|
342
|
+
Convert eBooks to Audiobooks using a Text-to-Speech model. You can either launch the
|
|
343
|
+
Gradio interface or run the script in headless mode for direct conversion.
|
|
344
|
+
|
|
345
|
+
options:
|
|
346
|
+
-h, --help show this help message and exit
|
|
347
|
+
--share SHARE Set to True to enable a public shareable Gradio link. Defaults
|
|
348
|
+
to False.
|
|
349
|
+
--headless HEADLESS Set to True to run in headless mode without the Gradio
|
|
350
|
+
interface. Defaults to False.
|
|
351
|
+
--ebook EBOOK Path to the ebook file for conversion. Required in headless
|
|
352
|
+
mode.
|
|
353
|
+
--voice VOICE Path to the target voice file for TTS. Optional, uses a default
|
|
354
|
+
voice if not provided.
|
|
355
|
+
--language LANGUAGE Language for the audiobook conversion. Options: en, es, fr, de,
|
|
356
|
+
it, pt, pl, tr, ru, nl, cs, ar, zh-cn, ja, hu, ko. Defaults to
|
|
357
|
+
English (en).
|
|
358
|
+
--use_custom_model USE_CUSTOM_MODEL
|
|
359
|
+
Set to True to use a custom TTS model. Defaults to False. Must
|
|
360
|
+
be True to use custom models, otherwise you'll get an error.
|
|
361
|
+
--custom_model CUSTOM_MODEL
|
|
362
|
+
Path to the custom model file (.pth). Required if using a custom
|
|
363
|
+
model.
|
|
364
|
+
--custom_config CUSTOM_CONFIG
|
|
365
|
+
Path to the custom config file (config.json). Required if using
|
|
366
|
+
a custom model.
|
|
367
|
+
--custom_vocab CUSTOM_VOCAB
|
|
368
|
+
Path to the custom vocab file (vocab.json). Required if using a
|
|
369
|
+
custom model.
|
|
370
|
+
--custom_model_url CUSTOM_MODEL_URL
|
|
371
|
+
URL to download the custom model as a zip file. Optional, but
|
|
372
|
+
will be used if provided. Examples include David Attenborough's
|
|
373
|
+
model: 'https://huggingface.co/drewThomasson/xtts_David_Attenbor
|
|
374
|
+
ough_fine_tune/resolve/main/Finished_model_files.zip?download=tr
|
|
375
|
+
ue'. More XTTS fine-tunes can be found on my Hugging Face at
|
|
376
|
+
'https://huggingface.co/drewThomasson'.
|
|
377
|
+
--temperature TEMPERATURE
|
|
378
|
+
Temperature for the model. Defaults to 0.65. Higher Tempatures
|
|
379
|
+
will lead to more creative outputs IE: more Hallucinations.
|
|
380
|
+
Lower Tempatures will be more monotone outputs IE: less
|
|
381
|
+
Hallucinations.
|
|
382
|
+
--length_penalty LENGTH_PENALTY
|
|
383
|
+
A length penalty applied to the autoregressive decoder. Defaults
|
|
384
|
+
to 1.0. Not applied to custom models.
|
|
385
|
+
--repetition_penalty REPETITION_PENALTY
|
|
386
|
+
A penalty that prevents the autoregressive decoder from
|
|
387
|
+
repeating itself. Defaults to 2.0.
|
|
388
|
+
--top_k TOP_K Top-k sampling. Lower values mean more likely outputs and
|
|
389
|
+
increased audio generation speed. Defaults to 50.
|
|
390
|
+
--top_p TOP_P Top-p sampling. Lower values mean more likely outputs and
|
|
391
|
+
increased audio generation speed. Defaults to 0.8.
|
|
392
|
+
--speed SPEED Speed factor for the speech generation. IE: How fast the
|
|
393
|
+
Narrerator will speak. Defaults to 1.0.
|
|
394
|
+
--enable_text_splitting ENABLE_TEXT_SPLITTING
|
|
395
|
+
Enable splitting text into sentences. Defaults to True.
|
|
396
|
+
|
|
397
|
+
Example: python script.py --headless --ebook path_to_ebook --voice path_to_voice
|
|
398
|
+
--language en --use_custom_model True --custom_model model.pth --custom_config
|
|
399
|
+
config.json --custom_vocab vocab.json
|
|
400
|
+
```
|
|
401
|
+
</details>
|
|
402
|
+
|
|
403
|
+
#### đĨī¸ Docker GUI
|
|
404
|
+

|
|
405
|
+
|
|
406
|
+
<details>
|
|
407
|
+
<summary>Click to see images of Web GUI</summary>
|
|
408
|
+
<img width="1728" alt="image" src="https://github.com/user-attachments/assets/b36c71cf-8e06-484c-a252-934e6b1d0c2f">
|
|
409
|
+
<img width="1728" alt="image" src="https://github.com/user-attachments/assets/c0dab57a-d2d4-4658-bff9-3842ec90cb40">
|
|
410
|
+
<img width="1728" alt="image" src="https://github.com/user-attachments/assets/0a99eeac-c521-4b21-8656-e064c1adc528">
|
|
411
|
+
</details>
|
|
412
|
+
### đ ī¸ For Custom Xtts Models
|
|
413
|
+
|
|
414
|
+
Models built to be better at a specific voice. Check out my Hugging Face page [here](https://huggingface.co/drewThomasson).
|
|
415
|
+
|
|
416
|
+
To use a custom model, paste the link of the `Finished_model_files.zip` file like this:
|
|
417
|
+
|
|
418
|
+
[David Attenborough fine tuned Finished_model_files.zip](https://huggingface.co/drewThomasson/xtts_David_Attenborough_fine_tune/resolve/main/Finished_model_files.zip?download=true)
|
|
419
|
+
|
|
420
|
+
For a custom model a ref audio clip of the voice will also be needed:
|
|
421
|
+
[ref audio clip of David Attenborough](https://huggingface.co/drewThomasson/xtts_David_Attenborough_fine_tune/blob/main/ref.wav)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
More details can be found at the [Dockerfile Hub Page]([https://github.com/DrewThomasson/ebook2audiobookXTTS](https://hub.docker.com/repository/docker/athomasson2/ebook2audiobookxtts/general)).
|
|
426
|
+
|
|
427
|
+
## đ Fine Tuned Xtts models
|
|
428
|
+
|
|
429
|
+
To find already fine-tuned XTTS models, visit [this Hugging Face link](https://huggingface.co/drewThomasson) đ. Search for models that include "xtts fine tune" in their names.
|
|
430
|
+
|
|
431
|
+
## đĨ Demos
|
|
432
|
+
|
|
433
|
+
Rainy day voice
|
|
434
|
+
|
|
435
|
+
https://github.com/user-attachments/assets/8486603c-38b1-43ce-9639-73757dfb1031
|
|
436
|
+
|
|
437
|
+
David Attenborough voice
|
|
438
|
+
|
|
439
|
+
https://github.com/user-attachments/assets/47c846a7-9e51-4eb9-844a-7460402a20a8
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
## đ¤ [Huggingface space demo](https://huggingface.co/spaces/drewThomasson/ebook2audiobookXTTS)
|
|
443
|
+
- Huggingface space is running on free cpu tier so expect very slow or timeout lol, just don't give it giant files is all
|
|
444
|
+
- Best to duplicate space or run locally.
|
|
445
|
+
|
|
446
|
+
## Free Google Colab [](https://colab.research.google.com/github/DrewThomasson/ebook2audiobookXTTS/blob/main/Notebooks/colab_ebook2audiobookxtts.ipynb)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
## đ Supported eBook Formats
|
|
451
|
+
|
|
452
|
+
- `.epub`, `.pdf`, `.mobi`, `.txt`, `.html`, `.rtf`, `.chm`, `.lit`, `.pdb`, `.fb2`, `.odt`, `.cbr`, `.cbz`, `.prc`, `.lrf`, `.pml`, `.snb`, `.cbc`, `.rb`, `.tcr`
|
|
453
|
+
- **Best results**: `.epub` or `.mobi` for automatic chapter detection
|
|
454
|
+
|
|
455
|
+
## đ Output
|
|
456
|
+
|
|
457
|
+
- Creates an `.m4b` file with metadata and chapters.
|
|
458
|
+
- **Example Output**: 
|
|
459
|
+
|
|
460
|
+
## đ ī¸ Common Issues:
|
|
461
|
+
- "It's slow!" - On CPU only this is very slow, and you can only get speedups though a NVIDIA GPU. [Discussion about this](https://github.com/DrewThomasson/ebook2audiobookXTTS/discussions/19#discussioncomment-10879846) For faster multilingual generation I would suggest my other [project that uses piper-tts](https://github.com/DrewThomasson/ebook2audiobookpiper-tts) instead(It doesn't have zero-shot voice cloning though, and is siri quality voices, but it is much faster on cpu.)
|
|
462
|
+
- "I'm having dependency issues" - Just use the docker, its fully self contained and has a headless mode, add `-h` parameter after the `app.py` in the docker run command for more information.
|
|
463
|
+
- "Im getting a truncated audio issue!" - PLEASE MAKE AN ISSUE OF THIS, I don't speak every language and I need advise from each person to fine tune my sentense splitting function on any other languages.đ
|
|
464
|
+
- "The loading bar is stuck at 30% in the web gui!" - The web gui loading bar is extreamly basic as its just split between the three loading steps, refer to the terminal and what sentense it's on for a more accurate gauge on where is it progress wise.
|
|
465
|
+
|
|
466
|
+
## What I need help with! đ
|
|
467
|
+
## [Full list of things can be found here](https://github.com/DrewThomasson/ebook2audiobookXTTS/issues/32)
|
|
468
|
+
- Any help from people speaking any of the supported langues to help with proper sentence splitting methods
|
|
469
|
+
- Potentially creating readme Guides for Multiple languages(Becuase the only language I know is English đ)
|
|
470
|
+
|
|
471
|
+
## đ Special Thanks
|
|
472
|
+
|
|
473
|
+
- **Coqui TTS**: [Coqui TTS GitHub](https://github.com/coqui-ai/TTS)
|
|
474
|
+
- **Calibre**: [Calibre Website](https://calibre-ebook.com)
|
|
475
|
+
|
|
476
|
+
- [@shakenbake15 for better chapter saving method](https://github.com/DrewThomasson/ebook2audiobookXTTS/issues/8)
|
|
477
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ebook2audiobook
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A package to convert ebooks to audiobooks
|
|
5
|
+
Author: Andrew Phillip Thomasson
|
|
6
|
+
Author-email: drew.thomasson100@gmail.com
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: coqui-tts==0.24.2
|
|
9
|
+
Requires-Dist: pydub
|
|
10
|
+
Requires-Dist: nltk
|
|
11
|
+
Requires-Dist: beautifulsoup4
|
|
12
|
+
Requires-Dist: ebooklib
|
|
13
|
+
Requires-Dist: tqdm
|
|
14
|
+
Requires-Dist: gradio==4.44.0
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
ebook2audiobook.egg-info/PKG-INFO
|
|
5
|
+
ebook2audiobook.egg-info/SOURCES.txt
|
|
6
|
+
ebook2audiobook.egg-info/dependency_links.txt
|
|
7
|
+
ebook2audiobook.egg-info/entry_points.txt
|
|
8
|
+
ebook2audiobook.egg-info/requires.txt
|
|
9
|
+
ebook2audiobook.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
from setuptools.command.install import install
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
|
|
6
|
+
class PostInstallCommand(install):
|
|
7
|
+
def run(self):
|
|
8
|
+
# Run the original install process
|
|
9
|
+
install.run(self)
|
|
10
|
+
|
|
11
|
+
# Import nltk only after dependencies are installed
|
|
12
|
+
import nltk
|
|
13
|
+
# Post-install NLTK download
|
|
14
|
+
nltk.download("punkt")
|
|
15
|
+
nltk.download("punkt_tab")
|
|
16
|
+
|
|
17
|
+
# Ensure default_voice.wav is available for app.py
|
|
18
|
+
default_voice_src = os.path.join(os.path.dirname(__file__), 'default_voice.wav')
|
|
19
|
+
default_voice_dest = os.path.join(os.path.expanduser("~"), '.ebook2audiobook', 'default_voice.wav')
|
|
20
|
+
os.makedirs(os.path.dirname(default_voice_dest), exist_ok=True)
|
|
21
|
+
shutil.copyfile(default_voice_src, default_voice_dest)
|
|
22
|
+
|
|
23
|
+
setup(
|
|
24
|
+
name="ebook2audiobook",
|
|
25
|
+
version="0.0.1",
|
|
26
|
+
author="Andrew Phillip Thomasson",
|
|
27
|
+
author_email="drew.thomasson100@gmail.com",
|
|
28
|
+
description="A package to convert ebooks to audiobooks",
|
|
29
|
+
packages=find_packages(),
|
|
30
|
+
install_requires=[
|
|
31
|
+
"coqui-tts==0.24.2",
|
|
32
|
+
"pydub",
|
|
33
|
+
"nltk",
|
|
34
|
+
"beautifulsoup4",
|
|
35
|
+
"ebooklib",
|
|
36
|
+
"tqdm",
|
|
37
|
+
"gradio==4.44.0"
|
|
38
|
+
],
|
|
39
|
+
cmdclass={
|
|
40
|
+
'install': PostInstallCommand,
|
|
41
|
+
},
|
|
42
|
+
entry_points={
|
|
43
|
+
'console_scripts': [
|
|
44
|
+
'ebook2audiobook=your_package.app:main',
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
package_data={
|
|
48
|
+
'': ['default_voice.wav'],
|
|
49
|
+
},
|
|
50
|
+
)
|
|
51
|
+
|