speaker_helper.eardrum.discover module
Discovery: the words of a text that are not in the lexicon yet, but should be.
Module summary
A lexicon only fixes the words somebody thought of. A document brings new ones every time — a surname, an acronym, a product, an English term in a French sentence — and the first time anyone notices is when the narration says it wrong. This module reads the text first and lists the words at risk, each with the reasons it was picked:
properCapitalised, but not because it opens a sentence (“Feynman”, “Grasse”).
acronymTwo or more capitals and no lowercase (“ONU”, “BMAD”, “GPT-4”).
mixedMixed case or letters with digits inside one word (“GitHub”, “ChatGPT”, “mp3”).
foreignespeak-ng itself switches language to read it (“Tailwind”, “Apple”).
Consecutive capitalised words make one phrase (“Van Gogh”, “Deep Blue”): the lexicon matches phrases, and a surname is often only wrong next to its first name. Words the lexicon already covers are left out — they are checked from the lexicon’s side.
Usage example
>>> [w.word for w in discover("Hier, Feynman parlait de l'ONU sur GitHub.", "fr")]
['Feynman', 'ONU', 'GitHub']
- class speaker_helper.eardrum.discover.Discovered(word, reasons=<factory>, count=0, example='')[source]
Bases:
objectA word of the text at risk of being mispronounced.
- speaker_helper.eardrum.discover.discover(text, language, *, known=None, foreign=None)[source]
List the words of
textlikely to be mispronounced.- Parameters:
text (str) – The document.
language (str) – ISO-639-1 code of the text.
known (callable or None) –
word -> bool: whether the lexicon already covers the word (those are skipped).Noneskips nothing.foreign (callable or None) –
(words, language) -> set: the words espeak reads as foreign (speaker_helper.eardrum.espeak.foreign_words()).Noneturns that rule off — handy in tests, and on machines without espeak.
- Returns:
In order of first appearance.
- Return type:
list of Discovered