Utilities API

This page documents utility modules and helper functions.

Token Context

class kokorog2p.en.lexicon.TokenContext(future_vowel: bool | None = None, future_to: bool = False)[source]

Bases: object

Context information for token processing.

future_vowel: bool | None = None
future_to: bool = False

Fallback Handling

The fallback module provides functionality for handling out-of-vocabulary words:

Fallback options for OOV words with IPA to Kokoro conversion.

class kokorog2p.en.fallback.EspeakFallback(british: bool = False, use_cli: bool = False)[source]

Bases: FallbackBase[EspeakBackend]

Fallback G2P using espeak-ng with Kokoro phoneme conversion.

install_hint: str = 'Check that espeak-ng is properly installed.'

Extra hint appended to backend-init error logs (RuntimeError).

backend_word_kokoro: bool = False

If True, pass convert_to_kokoro=True into backend.word_phonemes().

backend_text_kokoro: bool = True

If True, pass convert_to_kokoro=True into backend.phonemize().

__init__(british: bool = False, use_cli: bool = False) None[source]

Initialize the espeak fallback.

Args:

british: Whether to use British English.

class kokorog2p.en.fallback.GoruutFallback(british: bool = False)[source]

Bases: FallbackBase[GoruutBackend]

Fallback G2P using goruut with Kokoro phoneme conversion.

install_hint: str = 'Check that pygoruut is properly installed.'

Extra hint appended to backend-init error logs (RuntimeError).

backend_word_kokoro: bool = False

If True, pass convert_to_kokoro=True into backend.word_phonemes().

backend_text_kokoro: bool = True

If True, pass convert_to_kokoro=True into backend.phonemize().

__init__(british: bool = False) None[source]

Initialize the goruut fallback.

Args:

british: Whether to use British English.

Internal Utilities

These are internal utilities used by the library. They may change without notice.

Lexicon Utilities

Functions for working with lexicons and dictionaries.

Number Processing

Internal number processing utilities shared across languages.