Configuration API

VoiceConfig is the validated, immutable view of the Piper .onnx.json fields used by PiperG2P. PiperConfig is a compatibility alias. High-level config= arguments accept a path, mapping, or existing VoiceConfig; the lower-level frontend expects a VoiceConfig or path via from_config().

Strict parsing is the default. strict=False is a compatibility mode for legacy inputs that can infer supported defaults and emit CompatibilityWarning; it does not make unsupported phoneme providers available.

.. py:class:: VoiceConfig(num_symbols: int, num_speakers: int, sample_rate: int, phoneme_id_map: ~collections.abc.Mapping[str, tuple[int, …]], phoneme_type: ~piperg2p.config.PhonemeType = PhonemeType.ESPEAK, espeak_voice: str = ‘en-us’, speaker_id_map: ~collections.abc.Mapping[str, int] = , default_speaker_id: int = 0, noise_scale: float = 0.667, length_scale: float = 1.0, noise_w: float = 0.8, hop_length: int = 256, vowel_clusters: frozenset[tuple[str, …]] = , piper_version: str | None = None, extra: ~collections.abc.Mapping[str, ~typing.Any] = ) :module: piperg2p :canonical: piperg2p.config.VoiceConfig</p>

Bases: :py:class:object

Validated subset of a Piper .onnx.json voice configuration.

.. py:attribute:: VoiceConfig.num_symbols :module: piperg2p :type: int

.. py:attribute:: VoiceConfig.num_speakers :module: piperg2p :type: int

.. py:attribute:: VoiceConfig.sample_rate :module: piperg2p :type: int

.. py:attribute:: VoiceConfig.phoneme_id_map :module: piperg2p :type: ~collections.abc.Mapping[str, tuple[int, …]]

.. py:attribute:: VoiceConfig.phoneme_type :module: piperg2p :type: ~piperg2p.config.PhonemeType :value: ‘espeak’

.. py:attribute:: VoiceConfig.espeak_voice :module: piperg2p :type: str :value: ‘en-us’

.. py:attribute:: VoiceConfig.speaker_id_map :module: piperg2p :type: ~collections.abc.Mapping[str, int]

.. py:attribute:: VoiceConfig.default_speaker_id :module: piperg2p :type: int :value: 0

.. py:attribute:: VoiceConfig.noise_scale :module: piperg2p :type: float :value: 0.667

.. py:attribute:: VoiceConfig.length_scale :module: piperg2p :type: float :value: 1.0

.. py:attribute:: VoiceConfig.noise_w :module: piperg2p :type: float :value: 0.8

.. py:attribute:: VoiceConfig.hop_length :module: piperg2p :type: int :value: 256

.. py:attribute:: VoiceConfig.vowel_clusters :module: piperg2p :type: frozenset[tuple[str, …]]

.. py:attribute:: VoiceConfig.piper_version :module: piperg2p :type: str | None :value: None

.. py:attribute:: VoiceConfig.extra :module: piperg2p :type: ~collections.abc.Mapping[str, ~typing.Any]

.. py:method:: VoiceConfig.from_dict(raw: ~collections.abc.Mapping[str, ~typing.Any], *, strict: bool = True) -> ~piperg2p.config.VoiceConfig :module: piperg2p :classmethod:

.. py:method:: VoiceConfig.from_json(path: str | ~pathlib.Path, *, strict: bool = True) -> ~piperg2p.config.VoiceConfig :module: piperg2p :classmethod:

.. py:property:: VoiceConfig.noise_w_scale :module: piperg2p :type: float

.. py:method:: VoiceConfig.to_dict() -> dict[str, ~typing.Any] :module: piperg2p

.. py:class:: PhonemeType(*values) :module: piperg2p :canonical: piperg2p.config.PhonemeType

Bases: :py:class:str, :py:class:~enum.Enum

.. py:attribute:: PhonemeType.ESPEAK :module: piperg2p :value: ‘espeak’

.. py:attribute:: PhonemeType.TEXT :module: piperg2p :value: ‘text’

.. py:attribute:: PhonemeType.PINYIN :module: piperg2p :value: ‘pinyin’

.. py:attribute:: PhonemeType.HEBREW :module: piperg2p :value: ‘hebrew’

.. py:attribute:: PhonemeType.JAPANESE :module: piperg2p :value: ‘japanese’

.. py:attribute:: PhonemeType.THAI :module: piperg2p :value: ‘thai’

For the supported/unavailable distinction and the base eSpeak voice versus routing language, see phoneme types and voice configuration.

</section> </div>