tepub 0.2.0__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.
- tepub-0.2.0/LICENSE +21 -0
- tepub-0.2.0/PKG-INFO +541 -0
- tepub-0.2.0/README.md +494 -0
- tepub-0.2.0/pyproject.toml +97 -0
- tepub-0.2.0/setup.cfg +4 -0
- tepub-0.2.0/src/audiobook/__init__.py +1 -0
- tepub-0.2.0/src/audiobook/assembly.py +750 -0
- tepub-0.2.0/src/audiobook/chapters.py +340 -0
- tepub-0.2.0/src/audiobook/controller.py +633 -0
- tepub-0.2.0/src/audiobook/cover.py +54 -0
- tepub-0.2.0/src/audiobook/language.py +26 -0
- tepub-0.2.0/src/audiobook/models.py +45 -0
- tepub-0.2.0/src/audiobook/mp4chapters.py +140 -0
- tepub-0.2.0/src/audiobook/preprocess.py +284 -0
- tepub-0.2.0/src/audiobook/renderer.py +64 -0
- tepub-0.2.0/src/audiobook/state.py +192 -0
- tepub-0.2.0/src/audiobook/tts.py +148 -0
- tepub-0.2.0/src/audiobook/voices.py +134 -0
- tepub-0.2.0/src/cli/__init__.py +5 -0
- tepub-0.2.0/src/cli/commands/__init__.py +24 -0
- tepub-0.2.0/src/cli/commands/audiobook.py +488 -0
- tepub-0.2.0/src/cli/commands/config.py +473 -0
- tepub-0.2.0/src/cli/commands/export.py +124 -0
- tepub-0.2.0/src/cli/commands/extract.py +104 -0
- tepub-0.2.0/src/cli/commands/format.py +37 -0
- tepub-0.2.0/src/cli/commands/pipeline.py +91 -0
- tepub-0.2.0/src/cli/commands/resume.py +26 -0
- tepub-0.2.0/src/cli/commands/translate.py +57 -0
- tepub-0.2.0/src/cli/core.py +172 -0
- tepub-0.2.0/src/cli/debug/__init__.py +40 -0
- tepub-0.2.0/src/cli/debug/commands.py +166 -0
- tepub-0.2.0/src/cli/errors.py +43 -0
- tepub-0.2.0/src/cli/main.py +78 -0
- tepub-0.2.0/src/config/__init__.py +31 -0
- tepub-0.2.0/src/config/loader.py +150 -0
- tepub-0.2.0/src/config/models.py +208 -0
- tepub-0.2.0/src/config/templates.py +310 -0
- tepub-0.2.0/src/config/workspace.py +135 -0
- tepub-0.2.0/src/debug_tools/__init__.py +0 -0
- tepub-0.2.0/src/debug_tools/analysis.py +127 -0
- tepub-0.2.0/src/debug_tools/common.py +25 -0
- tepub-0.2.0/src/debug_tools/extraction_summary.py +145 -0
- tepub-0.2.0/src/debug_tools/files.py +22 -0
- tepub-0.2.0/src/debug_tools/inspect.py +34 -0
- tepub-0.2.0/src/debug_tools/pending.py +35 -0
- tepub-0.2.0/src/debug_tools/preview.py +22 -0
- tepub-0.2.0/src/debug_tools/skip_lists.py +51 -0
- tepub-0.2.0/src/epub_io/__init__.py +0 -0
- tepub-0.2.0/src/epub_io/path_utils.py +69 -0
- tepub-0.2.0/src/epub_io/reader.py +66 -0
- tepub-0.2.0/src/epub_io/resources.py +97 -0
- tepub-0.2.0/src/epub_io/selector.py +208 -0
- tepub-0.2.0/src/epub_io/toc_utils.py +48 -0
- tepub-0.2.0/src/epub_io/writer.py +89 -0
- tepub-0.2.0/src/extraction/__init__.py +0 -0
- tepub-0.2.0/src/extraction/cleaners.py +40 -0
- tepub-0.2.0/src/extraction/epub_export.py +125 -0
- tepub-0.2.0/src/extraction/image_export.py +135 -0
- tepub-0.2.0/src/extraction/markdown_export.py +387 -0
- tepub-0.2.0/src/extraction/pipeline.py +126 -0
- tepub-0.2.0/src/extraction/segments.py +239 -0
- tepub-0.2.0/src/injection/__init__.py +0 -0
- tepub-0.2.0/src/injection/engine.py +233 -0
- tepub-0.2.0/src/injection/html_ops.py +67 -0
- tepub-0.2.0/src/logging_utils/__init__.py +0 -0
- tepub-0.2.0/src/logging_utils/logger.py +29 -0
- tepub-0.2.0/src/state/__init__.py +0 -0
- tepub-0.2.0/src/state/base.py +175 -0
- tepub-0.2.0/src/state/models.py +99 -0
- tepub-0.2.0/src/state/resume.py +35 -0
- tepub-0.2.0/src/state/store.py +184 -0
- tepub-0.2.0/src/tepub.egg-info/PKG-INFO +541 -0
- tepub-0.2.0/src/tepub.egg-info/SOURCES.txt +99 -0
- tepub-0.2.0/src/tepub.egg-info/dependency_links.txt +1 -0
- tepub-0.2.0/src/tepub.egg-info/entry_points.txt +2 -0
- tepub-0.2.0/src/tepub.egg-info/requires.txt +21 -0
- tepub-0.2.0/src/tepub.egg-info/top_level.txt +12 -0
- tepub-0.2.0/src/translation/__init__.py +0 -0
- tepub-0.2.0/src/translation/controller.py +461 -0
- tepub-0.2.0/src/translation/languages.py +47 -0
- tepub-0.2.0/src/translation/polish.py +95 -0
- tepub-0.2.0/src/translation/prefilter.py +40 -0
- tepub-0.2.0/src/translation/prompt_builder.py +74 -0
- tepub-0.2.0/src/translation/providers/__init__.py +35 -0
- tepub-0.2.0/src/translation/providers/anthropic.py +53 -0
- tepub-0.2.0/src/translation/providers/base.py +39 -0
- tepub-0.2.0/src/translation/providers/deepl.py +90 -0
- tepub-0.2.0/src/translation/providers/gemini.py +63 -0
- tepub-0.2.0/src/translation/providers/grok.py +77 -0
- tepub-0.2.0/src/translation/providers/ollama.py +39 -0
- tepub-0.2.0/src/translation/providers/openai.py +77 -0
- tepub-0.2.0/src/translation/refusal_filter.py +50 -0
- tepub-0.2.0/src/web_templates/__init__.py +1 -0
- tepub-0.2.0/src/web_templates/assets/css/app.css +167 -0
- tepub-0.2.0/src/web_templates/assets/js/app.js +154 -0
- tepub-0.2.0/src/web_templates/index.html +34 -0
- tepub-0.2.0/src/webbuilder/__init__.py +7 -0
- tepub-0.2.0/src/webbuilder/assets.py +51 -0
- tepub-0.2.0/src/webbuilder/dom.py +144 -0
- tepub-0.2.0/src/webbuilder/exporter.py +160 -0
- tepub-0.2.0/tests/test_exceptions.py +156 -0
tepub-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Xiaolai Li
|
|
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.
|
tepub-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: tepub
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: TEPUB - Tools for EPUB: A comprehensive toolkit for EPUB processing including translation, audiobook generation, and export
|
|
5
|
+
Author-email: Xiaolai Li <xiaolai@xiaolai.li>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/xiaolai/tepub
|
|
8
|
+
Project-URL: Repository, https://github.com/xiaolai/tepub
|
|
9
|
+
Project-URL: Issues, https://github.com/xiaolai/tepub/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/xiaolai/tepub/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: epub,translation,audiobook,tts,ebook,nlp,i18n
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Text Processing :: Markup :: XML
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: Pillow>=10.2
|
|
28
|
+
Requires-Dist: cjk-text-formatter>=1.0.5
|
|
29
|
+
Requires-Dist: click>=8.1
|
|
30
|
+
Requires-Dist: ebooklib>=0.18
|
|
31
|
+
Requires-Dist: edge-tts>=6.1
|
|
32
|
+
Requires-Dist: langdetect>=1.0.9
|
|
33
|
+
Requires-Dist: lxml>=5.0
|
|
34
|
+
Requires-Dist: mutagen>=1.47
|
|
35
|
+
Requires-Dist: nltk>=3.9
|
|
36
|
+
Requires-Dist: openai>=1.0
|
|
37
|
+
Requires-Dist: portalocker>=3.0
|
|
38
|
+
Requires-Dist: pydantic>=2.6
|
|
39
|
+
Requires-Dist: pydub>=0.25
|
|
40
|
+
Requires-Dist: requests>=2.31
|
|
41
|
+
Requires-Dist: rich>=13.7
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: pytest>=8.3; extra == "dev"
|
|
44
|
+
Requires-Dist: pytest-cov>=4.1; extra == "dev"
|
|
45
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
46
|
+
Requires-Dist: black>=24.4; extra == "dev"
|
|
47
|
+
|
|
48
|
+
# TEPUB - Tools for EPUB
|
|
49
|
+
|
|
50
|
+
**Transform EPUB books into translations, audiobooks, and web pages – automatically.**
|
|
51
|
+
|
|
52
|
+
TEPUB is a comprehensive toolkit for processing EPUB files. Translate books into any language, create professional audiobooks with natural voices, export to markdown, or publish as interactive websites.
|
|
53
|
+
|
|
54
|
+
[](CHANGELOG.md)
|
|
55
|
+
[](https://www.python.org/downloads/)
|
|
56
|
+
[](LICENSE)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
### 📖 **Translation**
|
|
63
|
+
- **Multi-language support**: Translate to/from any language
|
|
64
|
+
- **AI-powered**: OpenAI GPT-4, Anthropic Claude, Google Gemini, xAI Grok, DeepL, or Ollama
|
|
65
|
+
- **Dual output modes**:
|
|
66
|
+
- **Bilingual**: Original and translation side-by-side (perfect for learning)
|
|
67
|
+
- **Translation-only**: Professional translated edition
|
|
68
|
+
- **Smart processing**: Auto-skip front/back matter, parallel translation, resume capability
|
|
69
|
+
|
|
70
|
+
### 🎧 **Audiobook Creation**
|
|
71
|
+
- **Dual TTS providers**:
|
|
72
|
+
- **Edge TTS** (Free): 57+ voices in multiple languages, no API key required
|
|
73
|
+
- **OpenAI TTS** (Premium): 6 high-quality voices with superior naturalness
|
|
74
|
+
- **Professional output**: M4A format with chapter markers and embedded cover art
|
|
75
|
+
- **Chapter management**: Export, edit, and update chapter titles and timestamps
|
|
76
|
+
- **Flexible control**: Adjustable speed, voice selection, resume support
|
|
77
|
+
- **Cost**: Free with Edge TTS, or ~$11-22 per 300-page book with OpenAI TTS
|
|
78
|
+
|
|
79
|
+
### 📱 **Export Formats**
|
|
80
|
+
- **Web**: Interactive HTML viewer with live translation toggle
|
|
81
|
+
- **Markdown**: Plain text with preserved formatting and images
|
|
82
|
+
- **EPUB**: Bilingual or translation-only editions
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Quick Start
|
|
87
|
+
|
|
88
|
+
### Installation
|
|
89
|
+
|
|
90
|
+
**Automatic (Mac/Linux)**
|
|
91
|
+
```bash
|
|
92
|
+
git clone https://github.com/xiaolai/tepub.git
|
|
93
|
+
cd tepub
|
|
94
|
+
./install.sh
|
|
95
|
+
source .venv/bin/activate
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Manual (All platforms)**
|
|
99
|
+
```bash
|
|
100
|
+
git clone https://github.com/xiaolai/tepub.git
|
|
101
|
+
cd tepub
|
|
102
|
+
python -m venv .venv
|
|
103
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
104
|
+
pip install -e .[dev]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
See [INSTALL.md](INSTALL.md) for detailed platform-specific instructions.
|
|
108
|
+
|
|
109
|
+
### Translation Setup
|
|
110
|
+
|
|
111
|
+
**1. Get an API key** from your preferred provider:
|
|
112
|
+
- [OpenAI](https://platform.openai.com/) (Recommended: GPT-4, ~$0.50-2.00/book)
|
|
113
|
+
- [Anthropic](https://console.anthropic.com/) (Claude, great for literature)
|
|
114
|
+
- [Ollama](https://ollama.com/) (Free, runs locally)
|
|
115
|
+
|
|
116
|
+
**2. Configure TEPUB:**
|
|
117
|
+
```bash
|
|
118
|
+
# Create .env file with your API key
|
|
119
|
+
echo 'OPENAI_API_KEY=sk-your-key-here' > .env
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Basic Usage
|
|
123
|
+
|
|
124
|
+
**Translate a book:**
|
|
125
|
+
```bash
|
|
126
|
+
tepub extract mybook.epub
|
|
127
|
+
tepub translate mybook.epub --to "Simplified Chinese"
|
|
128
|
+
tepub export mybook.epub --epub
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Create audiobook (Free Edge TTS):**
|
|
132
|
+
```bash
|
|
133
|
+
tepub extract mybook.epub
|
|
134
|
+
tepub audiobook generate mybook.epub
|
|
135
|
+
# Interactive voice selection will appear
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Create audiobook (Premium OpenAI TTS):**
|
|
139
|
+
```bash
|
|
140
|
+
tepub audiobook generate mybook.epub --tts-provider openai --voice nova
|
|
141
|
+
# Requires OPENAI_API_KEY in environment
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**All-in-one pipeline:**
|
|
145
|
+
```bash
|
|
146
|
+
tepub pipeline mybook.epub --to Spanish --epub
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Common Tasks
|
|
152
|
+
|
|
153
|
+
### Translation
|
|
154
|
+
|
|
155
|
+
**Translate to different languages:**
|
|
156
|
+
```bash
|
|
157
|
+
tepub pipeline book.epub --to "Simplified Chinese" --epub
|
|
158
|
+
tepub pipeline book.epub --to Spanish --epub
|
|
159
|
+
tepub pipeline book.epub --to French --epub
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Choose translation provider:**
|
|
163
|
+
```bash
|
|
164
|
+
tepub translate book.epub --to Spanish --provider anthropic
|
|
165
|
+
tepub translate book.epub --to Spanish --provider ollama
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Translation-only output (smaller file):**
|
|
169
|
+
```bash
|
|
170
|
+
tepub export book.epub --epub --output-mode translated-only
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Audiobooks
|
|
174
|
+
|
|
175
|
+
**Edge TTS (Free, 57+ voices):**
|
|
176
|
+
```bash
|
|
177
|
+
# Interactive voice selection
|
|
178
|
+
tepub audiobook generate book.epub
|
|
179
|
+
|
|
180
|
+
# Specify voice directly
|
|
181
|
+
tepub audiobook generate book.epub --voice en-US-GuyNeural # Male
|
|
182
|
+
tepub audiobook generate book.epub --voice en-US-JennyNeural # Female
|
|
183
|
+
tepub audiobook generate book.epub --voice en-GB-RyanNeural # British
|
|
184
|
+
|
|
185
|
+
# See all voices
|
|
186
|
+
edge-tts --list-voices
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**OpenAI TTS (Premium, 6 voices):**
|
|
190
|
+
```bash
|
|
191
|
+
# Standard quality (tts-1)
|
|
192
|
+
tepub audiobook generate book.epub --tts-provider openai --voice nova
|
|
193
|
+
|
|
194
|
+
# Higher quality (tts-1-hd)
|
|
195
|
+
tepub audiobook generate book.epub --tts-provider openai --tts-model tts-1-hd --voice nova
|
|
196
|
+
|
|
197
|
+
# Adjust speed
|
|
198
|
+
tepub audiobook generate book.epub --tts-provider openai --voice nova --tts-speed 1.2
|
|
199
|
+
|
|
200
|
+
# Available OpenAI voices:
|
|
201
|
+
# - alloy: Neutral, balanced
|
|
202
|
+
# - echo: Male, authoritative
|
|
203
|
+
# - fable: British, expressive
|
|
204
|
+
# - onyx: Deep male, professional
|
|
205
|
+
# - nova: Female, friendly
|
|
206
|
+
# - shimmer: Female, warm
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Custom cover image:**
|
|
210
|
+
```bash
|
|
211
|
+
tepub audiobook generate book.epub --cover-path ~/Pictures/mycover.jpg
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Chapter management:**
|
|
215
|
+
```bash
|
|
216
|
+
# Preview chapter structure before generating audiobook
|
|
217
|
+
tepub audiobook export-chapters book.epub
|
|
218
|
+
# Edit chapters.yaml to customize chapter titles
|
|
219
|
+
tepub audiobook generate book.epub # Uses custom titles from chapters.yaml
|
|
220
|
+
|
|
221
|
+
# Extract chapters from existing audiobook
|
|
222
|
+
tepub audiobook export-chapters audiobook.m4a
|
|
223
|
+
|
|
224
|
+
# Update audiobook with edited chapter markers
|
|
225
|
+
tepub audiobook update-chapters audiobook.m4a chapters.yaml
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Export
|
|
229
|
+
|
|
230
|
+
**Create web version:**
|
|
231
|
+
```bash
|
|
232
|
+
tepub export book.epub --web
|
|
233
|
+
# Opens browser with interactive viewer
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Export to markdown:**
|
|
237
|
+
```bash
|
|
238
|
+
tepub extract book.epub
|
|
239
|
+
# Markdown files created automatically in: book/markdown/
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Configuration
|
|
245
|
+
|
|
246
|
+
TEPUB uses a two-level configuration system:
|
|
247
|
+
|
|
248
|
+
### Global Config: `~/.tepub/config.yaml`
|
|
249
|
+
|
|
250
|
+
Apply settings to all books:
|
|
251
|
+
|
|
252
|
+
```yaml
|
|
253
|
+
# Translation
|
|
254
|
+
source_language: auto
|
|
255
|
+
target_language: Simplified Chinese
|
|
256
|
+
translation_workers: 3
|
|
257
|
+
|
|
258
|
+
primary_provider:
|
|
259
|
+
name: openai
|
|
260
|
+
model: gpt-4o
|
|
261
|
+
|
|
262
|
+
# Audiobook
|
|
263
|
+
audiobook_tts_provider: edge # or: openai
|
|
264
|
+
audiobook_workers: 3
|
|
265
|
+
|
|
266
|
+
# Skip rules
|
|
267
|
+
skip_rules:
|
|
268
|
+
- keyword: index
|
|
269
|
+
- keyword: appendix
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Per-Book Config: `book/config.yaml`
|
|
273
|
+
|
|
274
|
+
Created automatically when you run `tepub extract book.epub`. Override global settings:
|
|
275
|
+
|
|
276
|
+
```yaml
|
|
277
|
+
# Choose TTS provider
|
|
278
|
+
audiobook_tts_provider: openai
|
|
279
|
+
audiobook_tts_model: tts-1-hd
|
|
280
|
+
audiobook_voice: nova
|
|
281
|
+
|
|
282
|
+
# Or use Edge TTS
|
|
283
|
+
audiobook_tts_provider: edge
|
|
284
|
+
audiobook_voice: en-US-AriaNeural
|
|
285
|
+
|
|
286
|
+
# Custom cover
|
|
287
|
+
cover_image_path: ~/Pictures/mycover.jpg
|
|
288
|
+
|
|
289
|
+
# Output mode
|
|
290
|
+
output_mode: translated_only
|
|
291
|
+
|
|
292
|
+
# Skip specific sections
|
|
293
|
+
skip_rules:
|
|
294
|
+
- keyword: prologue
|
|
295
|
+
- keyword: epilogue
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
See [config.example.yaml](config.example.yaml) for all available options with detailed explanations.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Output Structure
|
|
303
|
+
|
|
304
|
+
### Translation
|
|
305
|
+
```
|
|
306
|
+
mybook.epub # Original
|
|
307
|
+
mybook/ # Workspace
|
|
308
|
+
├── config.yaml # Per-book settings
|
|
309
|
+
├── segments.json # Extracted content
|
|
310
|
+
├── state.json # Translation progress
|
|
311
|
+
└── markdown/ # Markdown export
|
|
312
|
+
├── 001_chapter-1.md
|
|
313
|
+
└── images/
|
|
314
|
+
mybook_bilingual.epub # Output: both languages
|
|
315
|
+
mybook_translated.epub # Output: translation only
|
|
316
|
+
mybook_web/ # Web viewer
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Audiobooks
|
|
320
|
+
```
|
|
321
|
+
mybook/
|
|
322
|
+
├── audiobook@edgetts/ # Edge TTS audiobooks
|
|
323
|
+
│ ├── mybook.m4b # Final audiobook
|
|
324
|
+
│ └── segments/ # Cached audio segments
|
|
325
|
+
└── audiobook@openaitts/ # OpenAI TTS audiobooks
|
|
326
|
+
├── mybook.m4b
|
|
327
|
+
└── segments/
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Provider-specific folders let you create both versions for comparison.
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Advanced Features
|
|
335
|
+
|
|
336
|
+
### Resume Interrupted Work
|
|
337
|
+
|
|
338
|
+
TEPUB automatically saves progress. To resume:
|
|
339
|
+
```bash
|
|
340
|
+
# Just run the same command again
|
|
341
|
+
tepub translate book.epub --to Spanish
|
|
342
|
+
tepub audiobook generate book.epub
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Parallel Processing
|
|
346
|
+
|
|
347
|
+
Speed up translation (uses more API credits):
|
|
348
|
+
```yaml
|
|
349
|
+
# In config.yaml
|
|
350
|
+
translation_workers: 5 # Default: 3
|
|
351
|
+
audiobook_workers: 5 # Default: 3
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Custom Translation Style
|
|
355
|
+
|
|
356
|
+
```yaml
|
|
357
|
+
# In config.yaml
|
|
358
|
+
prompt_preamble: |
|
|
359
|
+
You are a literary translator specializing in preserving artistic voice.
|
|
360
|
+
{language_instruction}
|
|
361
|
+
{mode_instruction}
|
|
362
|
+
Maintain the author's style, tone, metaphors, and cultural nuances.
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Selective File Processing
|
|
366
|
+
|
|
367
|
+
After extraction, edit `book/config.yaml`:
|
|
368
|
+
```yaml
|
|
369
|
+
# Only translate specific files
|
|
370
|
+
translation_files:
|
|
371
|
+
- Text/chapter-001.xhtml
|
|
372
|
+
- Text/chapter-002.xhtml
|
|
373
|
+
# - Text/appendix.xhtml # Commented = skipped
|
|
374
|
+
|
|
375
|
+
# Different files for audiobook
|
|
376
|
+
audiobook_files:
|
|
377
|
+
- Text/chapter-001.xhtml
|
|
378
|
+
# - Text/copyright.xhtml # Skip copyright in audiobook
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Debug Commands
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
tepub debug workspace book.epub # Show workspace info
|
|
385
|
+
tepub debug pending # What's left to translate
|
|
386
|
+
tepub debug show-skip-list # What was skipped
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Cost Estimates
|
|
392
|
+
|
|
393
|
+
### Translation (300-page book)
|
|
394
|
+
- **OpenAI GPT-4o**: ~$0.50-2.00
|
|
395
|
+
- **Anthropic Claude**: ~$0.30-1.50
|
|
396
|
+
- **Ollama (local)**: Free (requires powerful computer)
|
|
397
|
+
|
|
398
|
+
### Audiobook (300-page book, ~750,000 characters)
|
|
399
|
+
- **Edge TTS**: Free
|
|
400
|
+
- **OpenAI tts-1**: ~$11.25
|
|
401
|
+
- **OpenAI tts-1-hd**: ~$22.50
|
|
402
|
+
|
|
403
|
+
### Recommendations
|
|
404
|
+
- **Best Quality**: OpenAI GPT-4 + OpenAI TTS-1-HD (~$25 total)
|
|
405
|
+
- **Best Value**: OpenAI GPT-4 + Edge TTS (~$1.50 total)
|
|
406
|
+
- **Free**: Ollama + Edge TTS (requires local GPU)
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## Troubleshooting
|
|
411
|
+
|
|
412
|
+
### "API key not found"
|
|
413
|
+
```bash
|
|
414
|
+
# Set environment variable
|
|
415
|
+
export OPENAI_API_KEY="sk-your-key-here"
|
|
416
|
+
|
|
417
|
+
# Or create .env file
|
|
418
|
+
echo 'OPENAI_API_KEY=sk-your-key-here' > .env
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### "ModuleNotFoundError: No module named 'openai'"
|
|
422
|
+
```bash
|
|
423
|
+
pip install -e .[dev]
|
|
424
|
+
# Or specifically: pip install openai
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Audiobook has no sound
|
|
428
|
+
```bash
|
|
429
|
+
# Install FFmpeg
|
|
430
|
+
brew install ffmpeg # Mac
|
|
431
|
+
sudo apt install ffmpeg # Linux
|
|
432
|
+
# Windows: download from ffmpeg.org
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Translation fails
|
|
436
|
+
```bash
|
|
437
|
+
# Check status
|
|
438
|
+
tepub debug pending
|
|
439
|
+
|
|
440
|
+
# Reset errors and retry
|
|
441
|
+
rm book/state.json
|
|
442
|
+
tepub translate book.epub --to Spanish
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
More solutions: [GitHub Issues](https://github.com/xiaolai/tepub/issues)
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## Privacy & Security
|
|
450
|
+
|
|
451
|
+
- **Local processing**: Books stay on your computer (except API calls)
|
|
452
|
+
- **No telemetry**: TEPUB collects no usage data
|
|
453
|
+
- **Provider privacy**: Translation APIs see text but don't store it long-term
|
|
454
|
+
- **Maximum privacy**: Use Ollama for fully local operation
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## Requirements
|
|
459
|
+
|
|
460
|
+
- **Python**: 3.10 or newer (3.11+ recommended)
|
|
461
|
+
- **OS**: macOS, Linux, or Windows 10+
|
|
462
|
+
- **Disk**: ~500 MB
|
|
463
|
+
- **RAM**: 2-4 GB
|
|
464
|
+
- **FFmpeg**: Required for audiobooks (auto-installed on Mac/Linux)
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
## Support
|
|
469
|
+
|
|
470
|
+
- **Documentation**: You're reading it!
|
|
471
|
+
- **Installation**: [INSTALL.md](INSTALL.md)
|
|
472
|
+
- **Changelog**: [CHANGELOG.md](CHANGELOG.md)
|
|
473
|
+
- **Issues**: [GitHub Issues](https://github.com/xiaolai/tepub/issues)
|
|
474
|
+
- **Command help**: `tepub --help` or `tepub <command> --help`
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
## Credits
|
|
479
|
+
|
|
480
|
+
Built with:
|
|
481
|
+
- [ebooklib](https://github.com/aerkalov/ebooklib) - EPUB processing
|
|
482
|
+
- [edge-tts](https://github.com/rany2/edge-tts) - Free text-to-speech
|
|
483
|
+
- [OpenAI](https://openai.com/) - Translation and premium TTS
|
|
484
|
+
- [Rich](https://github.com/Textualize/rich) - Beautiful terminal output
|
|
485
|
+
- [Click](https://click.palletsprojects.com/) - CLI framework
|
|
486
|
+
- [Pydantic](https://pydantic.dev/) - Configuration validation
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## License
|
|
491
|
+
|
|
492
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## For Developers
|
|
497
|
+
|
|
498
|
+
<details>
|
|
499
|
+
<summary>Development Setup</summary>
|
|
500
|
+
|
|
501
|
+
```bash
|
|
502
|
+
git clone https://github.com/xiaolai/tepub.git
|
|
503
|
+
cd tepub
|
|
504
|
+
python -m venv .venv
|
|
505
|
+
source .venv/bin/activate
|
|
506
|
+
pip install -e .[dev]
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
**Run tests:**
|
|
510
|
+
```bash
|
|
511
|
+
pytest
|
|
512
|
+
pytest --cov=src --cov-report=html
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Code quality:**
|
|
516
|
+
```bash
|
|
517
|
+
ruff check src tests
|
|
518
|
+
black src tests
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
**Project structure:**
|
|
522
|
+
```
|
|
523
|
+
src/
|
|
524
|
+
├── cli/ # Command-line interface
|
|
525
|
+
├── extraction/ # EPUB extraction
|
|
526
|
+
├── translation/ # Translation pipeline
|
|
527
|
+
├── audiobook/ # TTS and audiobook creation
|
|
528
|
+
├── injection/ # Insert translations into EPUB
|
|
529
|
+
├── web_export/ # Web viewer generation
|
|
530
|
+
├── epub_io/ # EPUB reading/writing
|
|
531
|
+
├── config/ # Configuration management
|
|
532
|
+
└── state/ # Progress tracking
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
</details>
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
**Made with ❤️ for language learners, audiobook enthusiasts, and book lovers everywhere.**
|
|
540
|
+
|
|
541
|
+
**Version 0.2.0** | [Changelog](CHANGELOG.md) | [Issues](https://github.com/xiaolai/tepub/issues)
|