File size: 4,773 Bytes
619ba12
7539214
 
619ba12
 
 
 
 
 
 
f3a39d3
619ba12
 
7539214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
---
title: Ebook2audiobookEspeak
emoji: βš‘πŸ“–
colorFrom: blue
colorTo: yellow
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: mit
short_description: Convert ebook to audiobook with espeak
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference


# πŸ“š eBook to Audiobook Converter with eSpeak-ng

Convert eBooks to audiobooks with chapters and metadata using Calibre and eSpeak-ng. Supports multiple languages and customizable voice settings!

## 🌟 Features

- πŸ“– Converts eBooks to text format using Calibre.
- πŸ“š Splits eBooks into chapters for organized audio.
- πŸŽ™οΈ High-quality text-to-speech using eSpeak-ng.
- 🌍 Supports multiple languages and accents.
- πŸŽ›οΈ Customizable voice, speed, and pitch settings.
- πŸ–₯️ User-friendly Gradio web interface.
- ⚑ Designed to run lighting fast on only 100 MB ram.

## πŸ› οΈ Requirements

- Python 3.x
- `gradio` Python package
- Calibre (for eBook conversion)
- FFmpeg (for audiobook creation)
- eSpeak-ng (for text-to-speech)

## πŸ–₯️ Gradio Web Gui
<img width="1405" alt="Screenshot 2024-08-17 at 4 42 16β€―PM" src="https://github.com/user-attachments/assets/ee8f29be-b696-4d66-81de-00c85f1f5c66">

<img width="1407" alt="Screenshot 2024-08-17 at 4 42 22β€―PM" src="https://github.com/user-attachments/assets/7a060762-d4fc-41cc-96b2-071f33e50f0c">


### πŸ”§ Installation Instructions

1. **Install Python 3.x** from [Python.org](https://www.python.org/downloads/).

2. **Install Calibre**:
   - **Ubuntu**: `sudo apt-get install -y calibre`
   - **macOS**: `brew install calibre`
   - **Windows** (Admin Powershell): `choco install calibre`

3. **Install FFmpeg**:
   - **Ubuntu**: `sudo apt-get install -y ffmpeg`
   - **macOS**: `brew install ffmpeg`
   - **Windows** (Admin Powershell): `choco install ffmpeg`

4. **Install eSpeak-ng**:
   - **Ubuntu**: `sudo apt-get install -y espeak-ng`
   - **macOS**: `brew install espeak-ng`
   - **Windows** (Admin Powershell): `choco install espeak-ng`

5. **Install Python packages**:
   ```bash
   pip install gradio bs4 pydub nltk beautifulsoup4 ebooklib tqdm
   ```

   **For non-Latin languages**:
   ```bash
   python -m nltk.downloader punkt
   ```

## 🌐 Supported Languages and Voices

eSpeak-ng provides a variety of voices for different languages and accents:

- **Afrikaans**: `af`
- **Amharic**: `am`
- **Arabic**: `ar`
- **Bengali**: `bn`
- **Bosnian**: `bs`
- **Catalan**: `ca`
- **Chinese (Mandarin)**: `cmn`
- **Croatian**: `hr`
- **Czech**: `cs`
- **Danish**: `da`
- **Dutch**: `nl`
- **English (Great Britain)**: `en-gb`
- **English (America)**: `en-us`
- **Esperanto**: `eo`
- **Finnish**: `fi`
- **French**: `fr`
- **German**: `de`
- **Greek**: `el`
- **Hindi**: `hi`
- **Hungarian**: `hu`
- **Icelandic**: `is`
- **Italian**: `it`
- **Japanese**: `ja`
- **Korean**: `ko`
- **Latvian**: `lv`
- **Macedonian**: `mk`
- **Norwegian (BokmΓ₯l)**: `nb`
- **Polish**: `pl`
- **Portuguese (Brazil)**: `pt-br`
- **Portuguese (Portugal)**: `pt`
- **Russian**: `ru`
- **Spanish (Spain)**: `es`
- **Swedish**: `sv`
- **Turkish**: `tr`
- **Vietnamese**: `vi`
- **Welsh**: `cy`

## πŸš€ Usage

### πŸ–₯️ Gradio Web Interface

1. **Run the Script**:
   ```bash
   python gradio_launch.py
   ```

2. **Open the Web App**: Click the URL provided in the terminal to access the web app and convert eBooks.

## 🐳 Using Docker

You can also use Docker to run the eBook to Audiobook converter. This method ensures consistency across different environments and simplifies setup.

### πŸš€ Running the Docker Container

To run the Docker container and start the Gradio interface, use the following command:

```bash
docker run -it --rm -p 7860:7860 athomasson2/ebook2audiobookespeak:latest
```

This command will start the Gradio interface on port 7860. (localhost:7860)

For more details, visit the [Docker Hub Page](https://hub.docker.com/repository/docker/athomasson2/ebook2audiobookespeak/general).

## πŸ“š Supported eBook Formats

- `.epub`, `.pdf`, `.mobi`, `.txt`, `.html`, `.rtf`, `.chm`, `.lit`, `.pdb`, `.fb2`, `.odt`, `.cbr`, `.cbz`, `.prc`, `.lrf`, `.pml`, `.snb`, `.cbc`, `.rb`, `.tcr`
- **Best results**: `.epub` or `.mobi` for automatic chapter detection

## πŸ“‚ Output

- Creates an `.m4b` file with metadata and chapters.

## πŸŽ₯ Demo
https://github.com/user-attachments/assets/4decbfc3-b934-498a-935e-180336ecadc4



## πŸ™ Special Thanks

- **eSpeak-ng**: [eSpeak-ng GitHub](https://github.com/espeak-ng/espeak-ng)
- **Calibre**: [Calibre Website](https://calibre-ebook.com)
- **Inspiration from Smiling friends Spamtopia episode Season 2 Episode 7**
  ![maxresdefault](https://github.com/user-attachments/assets/a6c34117-36d6-4b20-b8c5-b58066a867fe)