aboutsummaryrefslogtreecommitdiff
path: root/app/converter/converter.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/converter/converter.py')
-rw-r--r--app/converter/converter.py21
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)