API reference
Types
- espeakng_runtime.Mode
alias of
Literal[‘auto’, ‘native’, ‘cli’]
The Mode type constrains backend selection. Use 'auto' to prefer native with CLI fallback, 'native' to require the ctypes backend, or 'cli' to force the subprocess backend.
Runtime
- class espeakng_runtime.EspeakRuntime(*, mode: Literal['auto', 'native', 'cli'] = 'auto', executable: str | None = None, library: str | None = None, data: str | None = None, timeout: float | None = None, prefer_exact_clauses: bool = False)[source]
Bases:
objectResolve and own one eSpeak backend.
Native calls are serialized process-wide because eSpeak’s public API uses global state, including the currently selected voice.
- property info: RuntimeInfo
- property native_probes: tuple[LibraryProbe, ...]
Probes from native library selection during construction.
Returns an empty tuple for CLI mode. Does not perform additional discovery when read.
- resolve_voice(voice: str, *, allow_mbrola: bool = False) Voice[source]
Resolve a caller voice request to a concrete eSpeak voice.
- phonemize(text: str, *, voice: str, separator: str | None = None, use_tie: bool = False, tie_char: str = '͡') str[source]
EspeakRuntime.resolve_voice(voice, allow_mbrola=False) returns the concrete Voice selected from the active eSpeak inventory. Language-style requests such as en-gb are resolved consistently for native and CLI backends. Normal requests exclude MBROLA entries unless allow_mbrola=True; explicit mb/… and mb-… requests are accepted.
RuntimeInfo.version_tuple contains the first numeric version sequence from RuntimeInfo.version, or () when no version is reported.
EspeakRuntime.native_probes returns the LibraryProbe records from native library selection during construction. For mode=”cli”, this is an empty tuple. Use runtime.info for the selected backend details and runtime.native_probes for what was considered during native selection.
Data models
- class espeakng_runtime.RuntimeInfo(requested_mode: Literal['auto', 'native', 'cli'], implementation: Literal['native', 'cli'], executable: str | None = None, library: str | None = None, data: str | None = None, source: str | None = None, version: str | None = None, exact_clause_api: bool = False, phoneme_output_api: Literal['cli', 'native-trace', 'native-translation'] | None = None, phoneme_parity: Literal['exact', 'best-effort'] | None = None, parity: Literal['exact', 'best-effort'] = 'best-effort', fallback_reason: str | None = None, fallback_code: Literal['native-unavailable', 'native-load-error', 'exact-clause-api-unavailable', 'native-init-failed'] | None = None)[source]
Bases:
objectResolved backend and capability information.
- requested_mode: Literal['auto', 'native', 'cli']
- implementation: Literal['native', 'cli']
- exact_clause_api: bool
- parity: Literal['exact', 'best-effort']
- class espeakng_runtime.Clause(phonemes: str, terminator: str | None = None, terminator_code: int | None = None, sentence_end: bool = False)[source]
Bases:
objectA phonemized clause plus its source terminator.
- phonemes: str
- sentence_end: bool
- class espeakng_runtime.EspeakInspection(executable: str | None, cli_available: bool, require_exact_clauses: bool, selected_library: str | None, selected_source: str | None, selected_data: str | None, candidates: tuple[LibraryProbe, ...] = ())[source]
Bases:
objectNon-initializing eSpeak capability and candidate inspection.
- cli_available: bool
- require_exact_clauses: bool
- candidates: tuple[LibraryProbe, ...]
- property native_available: bool
- property exact_native_available: bool
- property trace_native_available: bool
True when the selected native library exposes the phoneme trace API.
- class espeakng_runtime.LibraryCandidate(library: 'str', source: 'str', data: 'str | None' = None, explicit: 'bool' = False)[source]
Bases:
object- library: str
- source: str
- explicit: bool
- class espeakng_runtime.LibraryProbe(library: 'str', source: 'str', data: 'str | None', loadable: 'bool', exact_clause_api: 'bool', phoneme_trace_api: 'bool' = False, error: 'str | None' = None, missing_symbols: 'tuple[str, ...]' = ())[source]
Bases:
object- library: str
- source: str
- loadable: bool
- exact_clause_api: bool
- phoneme_trace_api: bool
Errors
Public exceptions for espeakng-runtime.
- exception espeakng_runtime.errors.EspeakError[source]
Bases:
RuntimeErrorBase class for runtime errors.
Bases:
EspeakErrorRaised when no requested eSpeak backend can be initialized.
- exception espeakng_runtime.errors.EspeakConflictError[source]
Bases:
EspeakErrorRaised when incompatible native eSpeak configurations share a process.
- exception espeakng_runtime.errors.PhonemizationError[source]
Bases:
EspeakErrorRaised when eSpeak fails while phonemizing text.
- exception espeakng_runtime.errors.VoiceNotFoundError[source]
Bases:
PhonemizationErrorRaised when eSpeak cannot select a requested voice.
- exception espeakng_runtime.errors.CapabilityError[source]
Bases:
EspeakErrorRaised when the active backend lacks a requested capability.