aboutsummaryrefslogtreecommitdiff
path: root/converter/config.py
blob: ec8498632fd5a93fd7a13d22be5e90bab778c6d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""Configuration for the audiobook converter.

Edit these values to change the default voice and processing behavior.
All paths are resolved relative to the project root, so the converter can
be run from any working directory.
"""

from pathlib import Path

# Project root (directory containing audiobook_converter.py)
BASE_DIR = Path(__file__).resolve().parent.parent

# =============================================================================
# VOICE MODES
# =============================================================================

VOICE_MODE_CUSTOM = "custom_voice"
VOICE_MODE_CLONE = "voice_clone"
VOICE_MODES = (VOICE_MODE_CUSTOM, VOICE_MODE_CLONE)

# =============================================================================
# QWEN API CONFIGURATION
# =============================================================================

QWEN_API_URL = "http://127.0.0.1:7860"  # CustomVoice demo endpoint
API_TIMEOUT = 300  # Seconds before an API call times out
MAX_RETRIES = 3  # Retry failed chunks

# =============================================================================
# CUSTOM VOICE SETTINGS (pre-built speakers, always uses the 1.7B model)
# =============================================================================

CUSTOM_VOICE_SPEAKER = "Vivian"
CUSTOM_VOICE_LANGUAGE = "English"
CUSTOM_VOICE_INSTRUCT = "Speak naturally and clearly, as if reading a dramatic book to an adult audience."
CUSTOM_VOICE_MODEL_SIZE = "1.7B"
CUSTOM_VOICE_SEED = -1
CUSTOM_VOICE_MODEL_ID = "Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice"

# Map canonical speaker names to the display names used by the qwen-tts Gradio demo.
SPEAKER_DISPLAY_NAMES = {
    "ryan": "Ryan",
    "serena": "Serena",
    "vivian": "Vivian",
    "uncle_fu": "Uncle Fu",
    "aiden": "Aiden",
    "ono_anna": "Ono Anna",
    "sohee": "Sohee",
    "eric": "Eric",
    "dylan": "Dylan",
}

# =============================================================================
# VOICE CLONE SETTINGS (clone a voice from a reference audio file)
# =============================================================================
# Voice clone requires the Base-model demo (Qwen3-TTS-12Hz-1.7B-Base), which
# exposes /run_voice_clone. The CustomVoice demo only exposes /run_instruct, so
# run the Base demo on a separate port and point this at it.

VOICE_CLONE_LANGUAGE = "English"
VOICE_CLONE_USE_XVECTOR_ONLY = False
VOICE_CLONE_MODEL_SIZE = "1.7B"
VOICE_CLONE_MAX_CHUNK_CHARS = 200
VOICE_CLONE_CHUNK_GAP = 0
VOICE_CLONE_SEED = -1
VOICE_CLONE_API_URL = "http://127.0.0.1:7861"

# =============================================================================
# PROCESSING SETTINGS
# =============================================================================

BOOKS_FOLDER = BASE_DIR / "input"  # Input folder
AUDIOBOOKS_FOLDER = BASE_DIR / "output"  # Output folder
CHUNKS_FOLDER = BASE_DIR / "chunks"  # Scratch space for per-chunk audio (cleaned per book)
LOGS_FOLDER = BASE_DIR / "logs"

CHUNK_SIZE_WORDS = 1500  # Words per TTS chunk
MIN_DELAY_BETWEEN_CHUNKS = 1  # Seconds between API calls
HEARTBEAT_INTERVAL_SECONDS = 30  # Print "still working" this often during a chunk

# =============================================================================
# AUDIO OUTPUT SETTINGS
# =============================================================================

AUDIO_FORMAT = "mp3"  # Default output container
AUDIO_FORMATS = ("mp3", "m4b", "ogg", "flac")
AUDIO_BITRATE = "128k"

SUPPORTED_FORMATS = [".txt", ".pdf", ".epub"]