diff options
| author | historia <historiavg@proton.me> | 2026-08-19 03:55:13 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-19 03:55:13 -0400 |
| commit | 87e5216cd287f411b2ffab04dbc435f48c1d4aae (patch) | |
| tree | d24346d6793233a2af6305f8463ae17765e00d44 /converter/audio.py | |
| parent | f1f8e899c46de80d7f9fbb8f0b53983e18167bd2 (diff) | |
| download | tts-audiobook-generator-87e5216cd287f411b2ffab04dbc435f48c1d4aae.tar.gz | |
refactor: config.py simplified
Diffstat (limited to 'converter/audio.py')
| -rw-r--r-- | converter/audio.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/converter/audio.py b/converter/audio.py index c9feeb8..6e5a910 100644 --- a/converter/audio.py +++ b/converter/audio.py @@ -12,6 +12,8 @@ from . import config logger = logging.getLogger(__name__) +CHUNKS_FOLDER = Path(__file__).resolve().parent.parent / "chunks" + def atempo_filters(speed: float) -> str: """Return a comma-joined ffmpeg ``atempo`` filter chain for ``speed``. @@ -272,7 +274,7 @@ def _collect_chunk_files(total_chunks: int, else: missing.append(i) continue - matches = sorted(config.CHUNKS_FOLDER.glob(f"chunk_{i:04d}.*")) + matches = sorted(CHUNKS_FOLDER.glob(f"chunk_{i:04d}.*")) if matches: chunk_files.append(matches[0]) else: @@ -311,7 +313,7 @@ def combine_chunks(total_chunks: int, output_path: Path, if missing_chunks: logger.warning("Missing chunks: %s", missing_chunks) - concat_list = config.CHUNKS_FOLDER / "_concat_list.txt" + concat_list = CHUNKS_FOLDER / "_concat_list.txt" try: with open(concat_list, "w", encoding="utf-8") as list_file: for chunk_file in chunk_files: @@ -380,7 +382,7 @@ def cleanup_chunks() -> None: try: chunk_count = 0 for pattern in ("chunk_*", "chapter_*"): - for chunk_file in config.CHUNKS_FOLDER.glob(pattern): + for chunk_file in CHUNKS_FOLDER.glob(pattern): try: if chunk_file.is_file(): chunk_file.unlink() @@ -462,9 +464,9 @@ def combine_chapters_to_m4b(chapter_files: List[Path], titles: List[str], logger.error("No chapter files provided") return False - concat_list = config.CHUNKS_FOLDER / "_concat_list.txt" - metadata_file = config.CHUNKS_FOLDER / "_chapters.txt" - speed_metadata_file = config.CHUNKS_FOLDER / "_chapters_speed.txt" + concat_list = CHUNKS_FOLDER / "_concat_list.txt" + metadata_file = CHUNKS_FOLDER / "_chapters.txt" + speed_metadata_file = CHUNKS_FOLDER / "_chapters_speed.txt" try: chapters = [] start_ms = 0 |
