@@ -49,13 +49,22 @@ python translate.py -i input_file -o output_file
4949| ` --openai_api_key ` | OpenAI API key |
5050| ` --gemini_api_key ` | Gemini API key |
5151
52- ### Performance
52+ ### Prompt Options
53+
54+ | Option | Description |
55+ | --------| -------------|
56+ | ` --text-cleanup ` | Enable OCR/typographic cleanup (fix broken lines, spacing, punctuation) |
57+ | ` --refine ` | Enable refinement pass: runs a second pass to polish translation quality and literary style |
58+
59+ ### TTS (Text-to-Speech)
5360
5461| Option | Description | Default |
5562| --------| -------------| ---------|
56- | ` -cs, --chunksize ` | Lines per chunk | 25 |
57- | ` --timeout ` | Request timeout (seconds) | 900 |
58- | ` --context-window ` | Context window size | 2048 |
63+ | ` --tts ` | Generate audio from translated text using Edge-TTS | disabled |
64+ | ` --tts-voice ` | TTS voice name | Auto-selected based on target language |
65+ | ` --tts-rate ` | Speech rate adjustment (e.g., ` +10% ` , ` -20% ` ) | +0% |
66+ | ` --tts-bitrate ` | Audio bitrate (e.g., ` 64k ` , ` 96k ` ) | 48k |
67+ | ` --tts-format ` | Audio output format: ` opus ` or ` mp3 ` | opus |
5968
6069### Display
6170
@@ -114,17 +123,30 @@ python translate.py -i book.txt -o book_fr.txt \
114123 -m your-model
115124```
116125
117- ### Performance Tuning
126+ ### With Prompt Options
127+
128+ ``` bash
129+ # OCR cleanup (fix broken lines, spacing from scanned documents)
130+ python translate.py -i scanned_book.txt -tl French --text-cleanup
131+
132+ # Refinement pass for higher quality literary translation
133+ python translate.py -i novel.epub -tl French --refine
134+
135+ # Both options combined
136+ python translate.py -i scanned_book.txt -tl French --text-cleanup --refine
137+ ```
138+
139+ ### With TTS (Text-to-Speech)
118140
119141``` bash
120- # Larger chunks for better context (needs more VRAM)
121- python translate.py -i book.txt -o book_fr.txt -cs 50
142+ # Generate audio with auto-selected voice
143+ python translate.py -i book.txt -tl French --tts
122144
123- # Smaller chunks for limited hardware
124- python translate.py -i book.txt -o book_fr.txt -cs 15
145+ # Specify voice and format
146+ python translate.py -i book.txt -tl French --tts --tts-voice fr-FR-DeniseNeural --tts-format mp3
125147
126- # Longer timeout for slow models
127- python translate.py -i book.txt -o book_fr.txt --timeout 1800
148+ # Adjust speech rate and quality
149+ python translate.py -i book.txt -tl French --tts --tts-rate " +10% " --tts-bitrate 96k
128150```
129151
130152---
@@ -151,6 +173,13 @@ MAX_TOKENS_PER_CHUNK=400 # Token-based chunking (default: 400 tokens)
151173# Languages
152174DEFAULT_SOURCE_LANGUAGE=English
153175DEFAULT_TARGET_LANGUAGE=French
176+
177+ # TTS
178+ TTS_ENABLED=false
179+ TTS_VOICE= # Auto-selected if empty
180+ TTS_RATE=+0%
181+ TTS_BITRATE=48k
182+ TTS_OUTPUT_FORMAT=opus
154183```
155184
156185---
@@ -161,11 +190,3 @@ DEFAULT_TARGET_LANGUAGE=French
161190| ------| ---------|
162191| 0 | Success |
163192| 1 | Error (check console output) |
164-
165- ---
166-
167- ## Output Location
168-
169- By default, translated files are saved in ` translated_files/ ` directory.
170-
171- Configure with ` OUTPUT_DIR ` environment variable.
0 commit comments