diff options
| author | historia <historiavg@proton.me> | 2026-08-26 01:43:41 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-26 01:43:41 -0400 |
| commit | acbd9ff2c91182d96c57ffb57bee6e9b3fcbcbd4 (patch) | |
| tree | e336c11f2a57cff5566e249aa5d5477a3dc63c55 /app/converter/converter.py | |
| parent | 104a0d65c1ba37847c15b64212b7fec8ba371ccb (diff) | |
| download | tts-audiobook-generator-acbd9ff2c91182d96c57ffb57bee6e9b3fcbcbd4.tar.gz | |
refactor: split tts.py into per-backend packages
Diffstat (limited to 'app/converter/converter.py')
| -rw-r--r-- | app/converter/converter.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/app/converter/converter.py b/app/converter/converter.py index 1abc85c..48d4987 100644 --- a/app/converter/converter.py +++ b/app/converter/converter.py @@ -15,7 +15,7 @@ from typing import Callable, Dict, List, Optional, Tuple from . import audio, chunking, config, cover, extractors from .audio import TrackMeta -from .tts import ( +from .clients import ( BACKENDS, BACKEND_AUDIOCPP, BACKEND_FASTER, @@ -228,7 +228,8 @@ class AudiobookConverter: if backend == BACKEND_FASTER: # The faster backend always voice-clones using a reference voice # configured on the server, so no local reference audio is needed. - self.tts = FasterTTSClient(voice=voice, api_url=api_url, + self.tts = FasterTTSClient(chunks_dir=CHUNKS_FOLDER, + voice=voice, api_url=api_url, quiet=quiet) elif backend == BACKEND_AUDIOCPP: # --voice picks the voice: a built-in speaker name on the @@ -237,13 +238,15 @@ class AudiobookConverter: # multi-model servers; instructions describe or style the # voice, request_options pass per-model controls through to # the server. - self.tts = AudioCppTTSClient(voice=voice, language=self.language, + self.tts = AudioCppTTSClient(chunks_dir=CHUNKS_FOLDER, + voice=voice, language=self.language, model_id=model_id, instructions=instructions, request_options=self.request_options, api_url=api_url, quiet=quiet) else: self.tts = QwenTTSClient( + chunks_dir=CHUNKS_FOLDER, voice_mode=voice_mode, voice_clone_ref_audio=voice_clone_ref_audio, voice_clone_ref_text=voice_clone_ref_text, @@ -398,7 +401,7 @@ class AudiobookConverter: self.current_outputs = [] # Start from a clean scratch folder so a previous crash can never # affect this run - audio.cleanup_chunks() + audio.cleanup_chunks(CHUNKS_FOLDER) logger.info("Extracting text...") book = extractors.extract_book(file_path) @@ -476,7 +479,7 @@ class AudiobookConverter: return False finally: # Always cleanup, even on failure or interrupt - audio.cleanup_chunks() + audio.cleanup_chunks(CHUNKS_FOLDER) def _convert_m4b_with_chapters(self, sections, stem: str, start_time: float, meta: Optional[TrackMeta] = None, @@ -519,7 +522,9 @@ class AudiobookConverter: return False output_path = AUDIOBOOKS_FOLDER / f"{stem}.{self.output_format}" - if not audio.combine_chapters_to_m4b(chapter_files, titles, output_path, speed=self.speed, + if not audio.combine_chapters_to_m4b(chapter_files, titles, output_path, + chunks_dir=CHUNKS_FOLDER, + speed=self.speed, meta=meta, cover=cover): return False duration = time.time() - start_time @@ -653,7 +658,9 @@ class AudiobookConverter: successful_chunks, total_chunks) return False - success = audio.combine_chunks(total_chunks, output_path, chunk_results=results, + success = audio.combine_chunks(total_chunks, output_path, + chunk_results=results, + chunks_dir=CHUNKS_FOLDER, speed=speed, output_format=output_format, intermediate=chapter is not None, meta=meta, cover=cover) |
