diff options
| author | historia <historiavg@proton.me> | 2026-08-20 17:05:21 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-20 17:05:21 -0400 |
| commit | 1f2142e7f610871a6bbe6498d0709d310fcbebb1 (patch) | |
| tree | dae5a4ec4187e3940aa11b433ba852226e124472 /converter/tts.py | |
| parent | 4d3530f63730b47870d25629802c0c41f0c9ffae (diff) | |
| download | tts-audiobook-generator-1f2142e7f610871a6bbe6498d0709d310fcbebb1.tar.gz | |
feat: tool scripts for server.json and voices.json
Diffstat (limited to 'converter/tts.py')
| -rw-r--r-- | converter/tts.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/converter/tts.py b/converter/tts.py index 741d9d3..a1c0b09 100644 --- a/converter/tts.py +++ b/converter/tts.py @@ -28,7 +28,7 @@ from typing import Any, Dict, List, Optional, Tuple from . import config from .audio import concat_audio_files, probe_duration_ms -from .chunking import MAX_REQUEST_WORDS, split_into_chunks +from .chunking import split_into_chunks logger = logging.getLogger(__name__) @@ -440,14 +440,14 @@ class QwenTTSClient(_BaseTTSClient): """Generate one audio chunk; returns its path in the chunks folder. The text is split into sub-requests of at most - ``MAX_REQUEST_WORDS`` words each (the book-level chunker + ``config.CHUNK_SIZE`` words each (the book-level chunker normally guarantees this already; the split is defense in depth against pathological input such as a punctuation-free run of text), and the audio files returned for the sub-requests are concatenated into one chunk file. """ try: - sub_texts = split_into_chunks(text, max_words=MAX_REQUEST_WORDS) + sub_texts = split_into_chunks(text, max_words=config.CHUNK_SIZE) if not sub_texts: raise RuntimeError("No text to synthesize") @@ -673,7 +673,7 @@ class FasterTTSClient(_BaseTTSClient): def generate_chunk(self, text: str, chunk_num: int) -> Optional[str]: """Generate one audio chunk; returns its path in the chunks folder.""" try: - sub_chunks = split_into_chunks(text, max_words=MAX_REQUEST_WORDS) + sub_chunks = split_into_chunks(text, max_words=config.CHUNK_SIZE) if not sub_chunks: raise RuntimeError("No text to synthesize") @@ -914,13 +914,13 @@ class AudioCppTTSClient(_BaseTTSClient): """Generate one audio chunk; returns its path in the chunks folder. The text is split into sub-requests of at most - ``MAX_REQUEST_WORDS`` words each (defense in depth against + ``config.CHUNK_SIZE`` words each (defense in depth against pathological input, matching the Gradio client), each sub-request returns a complete WAV file, and the parts are concatenated into one chunk file. """ try: - sub_texts = split_into_chunks(text, max_words=MAX_REQUEST_WORDS) + sub_texts = split_into_chunks(text, max_words=config.CHUNK_SIZE) if not sub_texts: raise RuntimeError("No text to synthesize") |
