speaker_helper.eardrum.espeak module
espeak-ng as the loop’s reading of plain text.
Module summary
Two jobs need a deterministic grapheme-to-phoneme reading:
the carrier sentence around a word (“Je vous parle de … aujourd’hui.”) is ordinary text, and its IPA tells the aligner where the word sits;
foreign-word detection: espeak-ng wraps a word it reads in another language in switch markers (
(en)tˈeɪlwɪnd(fr)), which is exactly the kind of word a French engine is likely to mangle.
The library is found the way speaker_helper.backends.kokoro.espeak_config()
finds it — a system install first, the espeakng-loader wheel last — but
without importing kokoro-onnx, which the eardrum extra does not need.
Usage example
>>> espeak_language("fr"), espeak_language("en-GB"), espeak_language("es")
('fr-fr', 'en-gb', 'es')
- speaker_helper.eardrum.espeak.SWITCH_MARKER = re.compile('\\((?:[a-z]{2,3}(?:-[a-z]{2,4})?)\\)')
espeak-ng’s switch marker, as in
(en)or(fr).
- speaker_helper.eardrum.espeak.espeak_ipa(text, language)[source]
espeak-ng’s IPA reading of
text, switch markers removed.
- speaker_helper.eardrum.espeak.espeak_language(code)[source]
The espeak-ng voice for an ISO-639-1 (or regional) language code.
- speaker_helper.eardrum.espeak.foreign_words(words, language)[source]
The words espeak-ng reads as belonging to another language.
- Parameters:
- Returns:
The subset espeak wrapped in a language switch.
- Return type:
Notes
Returns an empty set when espeak-ng is unavailable: detection then rests on the other rules (capitals, acronyms, mixed case), never on a crash.