Low-level frontend API

PiperFrontend is the lower-level voice-config-driven frontend. Most applications should start with the sibling-style facade documented on the high-level API page; use this class when you need direct backend, encoder, or lexicon adapter control.

Autodoc renders the constructor and public methods from the current implementation, avoiding a manually copied signature:

.. py:class:: PiperFrontend(config: ~piperg2p.config.VoiceConfig, *, backend: ~piperg2p.backends.base.PhonemeBackend | None = None, espeak_mode: ~typing.Literal[‘auto’, ‘native’, ‘cli’] = ‘auto’, missing: ~piperg2p.codec.MissingPhonemePolicy | str = MissingPhonemePolicy.WARN, lexicons: ~collections.abc.Sequence[str] = (), lexicon_store: ~typing.Any = None, lexicon_backend: ~piperg2p.lexicons.base.PronunciationLookup | None = None, use_espeak_fallback: bool = True) :module: piperg2p :canonical: piperg2p.frontend.PiperFrontend

Bases: :py:class:object

Voice-config-driven Piper frontend independent from Piper’s runtime.

.. py:method:: PiperFrontend.init(config: ~piperg2p.config.VoiceConfig, *, backend: ~piperg2p.backends.base.PhonemeBackend | None = None, espeak_mode: ~typing.Literal[‘auto’, ‘native’, ‘cli’] = ‘auto’, missing: ~piperg2p.codec.MissingPhonemePolicy | str = MissingPhonemePolicy.WARN, lexicons: ~collections.abc.Sequence[str] = (), lexicon_store: ~typing.Any = None, lexicon_backend: ~piperg2p.lexicons.base.PronunciationLookup | None = None, use_espeak_fallback: bool = True) -> None :module: piperg2p

.. py:method:: PiperFrontend.from_config(path: str | ~pathlib.Path, **kwargs: ~typing.Any) -> ~piperg2p.frontend.PiperFrontend :module: piperg2p :classmethod:

.. py:method:: PiperFrontend.encode(phonemes: ~collections.abc.Iterable[str]) -> ~piperg2p.types.EncodeResult :module: piperg2p

.. py:property:: PiperFrontend.diagnostics :module: piperg2p :type: ~piperg2p.diagnostics.FrontendDiagnostics

.. py:method:: PiperFrontend.phonemize_prepared(text: str, *, annotations: ~collections.abc.Sequence[~typing.Any] | None = None) -> ~piperg2p.types.PhonemizeResult :module: piperg2p

.. py:method:: PiperFrontend.phonemize(text: str, *, annotations: ~collections.abc.Sequence[~typing.Any] | None = None) -> ~piperg2p.types.PhonemizeResult :module: piperg2p

.. py:method:: PiperFrontend.close() -> None :module: piperg2p

PiperFrontend.phonemize() aliases its low-level phonemize_prepared() and returns a PhonemizeResult (unlike PiperG2P.phonemize(), which returns str). The frontend accepts a validated VoiceConfig; from_config() loads a JSON path. Runtime lexicon selection is optional, mutually exclusive between managed identifiers and an injected backend, and supported only for phoneme_type="espeak". The voice’s phoneme_id_map remains authoritative.

See the configuration reference, result types, and backend guide for details.