speaker_helper.config module
Configuration for speaker-helper.
Module summary
speaker-helper reads a small, typed configuration describing where the
Voicebox engine lives and which voice / language / mode to use. Values come
from (in increasing precedence) dataclass defaults, an optional
settings.yaml, and SPEAKER_HELPER_* environment variables. Strings
spelled ${VAR} inside the YAML are expanded from the environment at load
time so hosts and secrets never sit in a committed file.
See settings.yaml.example and speaker_config.json.example at the
repository root for a documented template.
Usage example
>>> from speaker_helper.config import Settings
>>> s = Settings.from_yaml_text("voicebox: {port: 17600}\nlanguage: fr")
>>> s.voicebox.port
17600
>>> s.base_url
'http://127.0.0.1:17600'
- class speaker_helper.config.Settings(voicebox=<factory>, backend='voicebox', engine='kokoro', voice_id='', language='fr', normalize=True, mode='offline', first_chunk_sentences=1, mock=<factory>, clone=<factory>)[source]
Bases:
objectTop-level speaker-helper configuration.
- Parameters:
voicebox (VoiceboxConfig) – Connection details for the Voicebox engine.
backend (str) – Which TTS backend to drive:
"voicebox"(the real engine, default) or"mock"(deterministic, serverless — used by tests and the evaluation layer). The backend is an implementation detail; the rest of the package talks only to theTTSEngineprotocol. Seespeaker_helper.engine.available_backends().engine (str) – Backend-specific engine/model id. For Voicebox,
kokorois fast enough for real-time on CPU.voice_id (str) – Preset voice id. Empty (default) means “auto-pick a voice whose language matches
language”.language (str) – ISO-639-1 target language (e.g.
"fr").normalize (bool) – Ask Voicebox to loudness-normalise the output.
mode (str) –
"offline"or"streaming".first_chunk_sentences (int) – Streaming only: sentences in the first emitted chunk (1 → lowest TTFA).
Notes
Precedence, lowest to highest: dataclass defaults →
settings.yaml→SPEAKER_HELPER_*environment variables.- classmethod from_mapping(mapping)[source]
Build settings from a plain mapping (unknown keys ignored).
- classmethod load(path=None)[source]
Load settings from a YAML file if present, else defaults + env.
- voicebox: VoiceboxConfig
- class speaker_helper.config.VoiceboxConfig(host='127.0.0.1', port=17493, timeout_s=300.0, max_retries=2, retry_backoff_s=0.5)[source]
Bases:
objectWhere the Voicebox REST service lives.
- Parameters:
host (str) – Hostname or IP of the Voicebox server. Default
127.0.0.1.port (int) – TCP port. Voicebox’s native default is
17493; the bundleddocker-composemaps the container to17600on the host.timeout_s (float) – Per-request timeout in seconds. The first synthesis of a new engine pays a model download, so keep this generous.
max_retries (int) – How many times to retry a request that fails on a transient error (network/transport error or a 5xx from the engine).
0disables retries. Client errors (4xx) are never retried.retry_backoff_s (float) – Base delay for exponential backoff between retries: attempt
kwaitsretry_backoff_s * 2**(k-1)seconds.