API reference

Synthesis Classes

class voxpopuli.Phoneme(name: str, duration: int, pitch_mods: List[Tuple[int, int]] = None)

Stores the phonetic data for a single phoneme:

  • the name of the phoneme in SAMPA notation (depends on the language)
  • its duration (in milliseconds)
  • its pitch modifications (as a list of (percentage, pitch) tuples)
__init__(name: str, duration: int, pitch_mods: List[Tuple[int, int]] = None)

Initialize self. See help(type(self)) for accurate signature.

__str__()

Return str(self).

classmethod from_str(pho_str)

Instanciates a phoneme from a line of espeak’s phoneme output.

set_from_pitches_list(pitch_list: List[int])

Set pitches variations from a list of frequencies. The pitch variation are set to be equidistant from one another.

class voxpopuli.PhonemeList(blocks: Union[voxpopuli.phonemes.Phoneme, Iterable[voxpopuli.phonemes.Phoneme]])

A list of phonemes. Can be printed into a .pho string formatted file

__add__(other: voxpopuli.phonemes.PhonemeList)

Concatenate two PhonemeList

__delitem__(index: int)

Remove a phoneme at index i in PhonemeList

__getitem__(index: int) → voxpopuli.phonemes.Phoneme

Get phoneme in PhonemeList

__init__(blocks: Union[voxpopuli.phonemes.Phoneme, Iterable[voxpopuli.phonemes.Phoneme]])

Initialize self. See help(type(self)) for accurate signature.

__iter__() → Iterable[voxpopuli.phonemes.Phoneme]

Iterate over PhonemeList

__len__() → int

Number of phonemes in PhonemeList

__setitem__(index: int, value: voxpopuli.phonemes.Phoneme)

Set phoneme in PhonemeList at index i

__str__()

Return str(self).

append(value: voxpopuli.phonemes.Phoneme)

Append a phoneme to PhonemeList

classmethod from_pho_str(pho_str_list: str)

Build a PhonemeList from a string corresponding to a .pho file typically produced by Espeak.

insert(index, value: voxpopuli.phonemes.Phoneme)

Insert a phoneme at index i in PhonemeList

phonemes_str

Output the PhonemeList as a .pho compatible string.

class voxpopuli.Voice(speed: int = 160, pitch: int = 50, lang: str = 'fr', voice_id: int = None, volume: float = None)
exception InvalidVoiceParameters
__init__(speed: int = 160, pitch: int = 50, lang: str = 'fr', voice_id: int = None, volume: float = None)

All parameters are optional, but it’s still advised that you pick a language, else it will default to French, which is a default to the most beautiful language on earth. Any invalid parameter will raise an InvalidVoiceParameter exception.

classmethod get_voices_for_lang(lang: str) → List[voxpopuli.main.Voice]

Get instances of all the available voices for a particular language

classmethod list_voice_ids() → Dict[str, List[T]]

Returns a dictionary listing available voice id’s for each language

say(speech: Union[voxpopuli.phonemes.PhonemeList, str])

Renders a string or a PhonemeList object to audio, then plays it using the PyAudio lib

to_audio(speech: Union[voxpopuli.phonemes.PhonemeList, str], filename=None) → bytes

Renders a str or a PhonemeList to a wave byte object. If a filename is specified, it saves the audio file to wave as well Throws a InvalidVoiceParameters if the voice isn’t found

to_phonemes(text: str) → voxpopuli.phonemes.PhonemeList

Renders a str to a `PhonemeList object.

SAMPA Phoneme Sets

class voxpopuli.FrenchPhonemes
CONSONANTS = {'H', 'J', 'N', 'R', 'S', 'Z', 'b', 'd', 'f', 'g', 'j', 'k', 'l', 'm', 'n', 'p', 's', 't', 'v', 'w', 'z'}
FRICATIVES = {'S', 'Z', 'f', 'j', 's', 'v', 'z'}
INDETERMINATE_WOVELS = {'&/', 'A/', 'E/', 'O/', 'U~/'}
LIQUIDS = {'H', 'R', 'j', 'l', 'w'}
NASAL_CONSONANTS = {'J', 'N', 'm', 'n'}
NASAL_WOVELS = {'9~', 'a~', 'e~', 'o~'}
ORALS = {'2', '9', '@', 'A', 'E', 'O', 'a', 'e', 'i', 'o', 'u', 'y'}
PLOSIVES = {'b', 'd', 'g', 'k', 'p', 't'}
STRESSES = {'"', '%', "'", ':', '`'}
VOWELS = {'&/', '2', '9', '9~', '@', 'A', 'A/', 'E', 'E/', 'O', 'O/', 'U~/', 'a', 'a~', 'e', 'e~', 'i', 'o', 'o~', 'u', 'y'}
all = {'"', '%', '&/', "'", '2', '9', '9~', ':', '@', 'A', 'A/', 'E', 'E/', 'H', 'J', 'N', 'O', 'O/', 'R', 'S', 'U~/', 'Z', '`', 'a', 'a~', 'b', 'd', 'e', 'e~', 'f', 'g', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'o~', 'p', 's', 't', 'u', 'v', 'w', 'y', 'z'}
class voxpopuli.BritishEnglishPhonemes
ADDITIONALS = {'?', 'x'}
AFFRICATES = {'dZ', 'tS'}
CENTRAL = {'@'}
CHECKED = {'I', 'Q', 'U', 'V', 'e', '{'}
CONSONANTS = {'D', 'N', 'S', 'T', 'Z', 'b', 'd', 'dZ', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'tS', 'v', 'w', 'z'}
FREE = {'3:', '@U', 'A:', 'I@', 'O:', 'OI,', 'U@', 'aI', 'aU,', 'e@', 'eI', 'i:', 'u:'}
FRICATIVES = {'D', 'S', 'T', 'Z', 'f', 'h', 's', 'v', 'z'}
GLIDES = {'j', 'w'}
INDETERMINATE = {'i', 'u'}
LIQUIDS = {'l', 'r'}
NASALS = {'N', 'm', 'n'}
PLOSIVES = {'b', 'd', 'g', 'k', 'p', 't'}
SONORANTS = {'N', 'j', 'l', 'm', 'n', 'r', 'w'}
STRESSES = {'"', '%', "'", ':', '`'}
VOWELS = {'3:', '@', '@U', 'A:', 'I', 'I@', 'O:', 'OI,', 'Q', 'U', 'U@', 'V', 'aI', 'aU,', 'e', 'e@', 'eI', 'i', 'i:', 'u', 'u:', '{'}
all = {'"', '%', "'", '3:', ':', '?', '@', '@U', 'A:', 'D', 'I', 'I@', 'N', 'O:', 'OI,', 'Q', 'S', 'T', 'U', 'U@', 'V', 'Z', '`', 'aI', 'aU,', 'b', 'd', 'dZ', 'e', 'e@', 'eI', 'f', 'g', 'h', 'i', 'i:', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'tS', 'u', 'u:', 'v', 'w', 'x', 'z', '{'}
class voxpopuli.AmericanEnglishPhonemes
CONSONANTS = {'D', 'N', 'S', 'T', 'Z', 'b', 'd', 'dZ', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'tS', 'v', 'w', 'z'}
STRESSES = {'"', '%', "'", ':', '`'}
VOWELS = {'3`', '@', '@`', 'A', 'E', 'I', 'O', 'OI', 'U', 'V', 'aI', 'aU', 'e', 'i', 'o', 'u', '{'}
all = {'"', '%', "'", '3`', ':', '@', '@`', 'A', 'D', 'E', 'I', 'N', 'O', 'OI', 'S', 'T', 'U', 'V', 'Z', '`', 'aI', 'aU', 'b', 'd', 'dZ', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'tS', 'u', 'v', 'w', 'z', '{'}
class voxpopuli.SpanishPhonemes
ACCENTS = {'"'}
AFFRICATES = {'jj', 'tS'}
CONSONANTS = {'B', 'D', 'G', 'J', 'L', 'T', 'b', 'd', 'f', 'g', 'jj', 'k', 'l', 'm', 'n', 'p', 'r', 'rr', 's', 't', 'tS', 'x'}
FRICATIVES = {'B', 'D', 'G', 'T', 'f', 's', 'x'}
LIQUIDS = {'L', 'l', 'r', 'rr'}
NASAL = {'J', 'm', 'n'}
PLOSIVES = {'b', 'd', 'g', 'k', 'p', 't'}
STRESSES = {'"', '%', "'", ':', '`'}
VOWELS = {'a', 'e', 'i', 'o', 'u'}
all = {'"', '%', "'", ':', 'B', 'D', 'G', 'J', 'L', 'T', '`', 'a', 'b', 'd', 'e', 'f', 'g', 'i', 'jj', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 'rr', 's', 't', 'tS', 'u', 'x'}
class voxpopuli.GermanPhonemes
AFFRICATES = {'dZ', 'pf', 'tS', 'ts'}
CENTRING_DIPHTONGS = {'2:6', '6', '96', 'E6', 'E:6', 'I6', 'O6', 'U6', 'Y6', 'a6', 'a:6', 'e:6', 'i:6', 'o:6', 'u:6', 'y:6'}
CHECKED = {'9', 'E', 'I', 'O', 'U', 'Y', 'a'}
CONSONANTS = {'C', 'N', 'R', 'S', 'Z', 'b', 'd', 'dZ', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'pf', 's', 't', 'tS', 'ts', 'v', 'x', 'z'}
DIPHTONGS = {'OY', 'aI', 'aU'}
FRICATIVES = {'C', 'S', 'Z', 'f', 'h', 'j', 's', 'v', 'x', 'z'}
GLOTTAL_STOP = '?'
PLOSIVES = {'b', 'd', 'g', 'k', 'p', 't'}
PURE = {'2:', 'E:', 'a:', 'e:', 'i:', 'o:', 'u:', 'y:'}
SCHWA = {'@'}
SONORANTS = {'N', 'R', 'l', 'm', 'n'}
STRESSES = {'"', '%', "'", ':', '`'}
VOWELS = {'2:', '9', 'E', 'E:', 'I', 'O', 'OY', 'U', 'Y', 'a', 'a:', 'aI', 'aU', 'e:', 'i:', 'o:', 'u:', 'y:'}
all = {'"', '%', "'", '2:', '2:6', '6', '9', '96', ':', '@', 'C', 'E', 'E6', 'E:', 'E:6', 'I', 'I6', 'N', 'O', 'O6', 'OY', 'R', 'S', 'U', 'U6', 'Y', 'Y6', 'Z', '`', 'a', 'a6', 'a:', 'a:6', 'aI', 'aU', 'b', 'd', 'dZ', 'e:', 'e:6', 'f', 'g', 'h', 'i:', 'i:6', 'j', 'k', 'l', 'm', 'n', 'o:', 'o:6', 'p', 'pf', 's', 't', 'tS', 'ts', 'u:', 'u:6', 'v', 'x', 'y:', 'y:6', 'z'}
class voxpopuli.ItalianPhonemes
ACCENTS = {''}
AFFRICATES = {'dZ', 'ddZ', 'ddz', 'dz', 'tS', 'ts', 'ttS', 'tts'}
CONSONANTS = {'J', 'JJ', 'L', 'LL', 'S', 'SS', 'b', 'bb', 'd', 'dZ', 'dd', 'ddZ', 'ddz', 'dz', 'f', 'ff', 'g', 'gg', 'k', 'kk', 'l', 'll', 'm', 'mm', 'n', 'nn', 'p', 'pp', 'r', 'rr', 's', 'ss', 't', 'tS', 'ts', 'tt', 'ttS', 'tts', 'v', 'vv', 'z'}
FRICATIVES = {'S', 'SS', 'f', 'ff', 's', 'ss', 'v', 'vv', 'z'}
GEMINATE_AFFRICATES = {'dZ', 'ddZ', 'ddz', 'dz', 'tS', 'ts', 'ttS', 'tts'}
GEMINATE_FRICATIVES = {'SS', 'ff', 'ss', 'vv'}
GEMINATE_LIQUIDS = {'LL', 'll', 'rr'}
GEMINATE_NASAL = {'JJ', 'mm', 'nn'}
GEMINATE_PLOSIVES = {'bb', 'dd', 'gg', 'kk', 'pp', 'tt'}
LIQUIDS = {'L', 'LL', 'l', 'll', 'r', 'rr'}
NASAL = {'J', 'JJ', 'm', 'mm', 'n', 'nn'}
PLOSIVES = {'b', 'bb', 'd', 'dd', 'g', 'gg', 'k', 'kk', 'p', 'pp', 't', 'tt'}
SEMIVOWELS = {'j', 'w'}
SINGLE_AFFRICATES = {'dZ', 'ddZ', 'ddz', 'dz', 'tS', 'ts', 'ttS', 'tts'}
SINGLE_FRICATIVES = {'S', 'f', 's', 'v', 'z'}
SINGLE_LIQUIDS = {'L', 'l', 'r'}
SINGLE_NASAL = {'J', 'm', 'n'}
SINGLE_PLOSIVES = {'b', 'd', 'g', 'k', 'p', 't'}
VOWELS = {'E', 'O', 'a', 'e', 'i', 'o', 'u'}
class voxpopuli.PortuguesePhonemes
CONSONANTS = {'J', 'L', 'R', 'S', 'Z', 'b', 'd', 'f', 'g', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'z'}
FRICATIVES = {'S', 'Z', 'f', 's', 'v', 'z'}
LIQUIDS = {'L', 'R', 'l', 'r'}
NASALS = {'J', 'm', 'n'}
PLOSIVES = {'b', 'd', 'g', 'k', 'p', 't'}
STRESSES = {'"', '%', "'", ':', '`'}
VOWELS = {'6', '6~', '6~j~', '@', 'E', 'O', 'a', 'aj', 'aw', 'e', 'e~', 'i', 'i~', 'o', 'o~', 'u', 'u~'}
all = {'"', '%', "'", '6', '6~', '6~j~', ':', '@', 'E', 'J', 'L', 'O', 'R', 'S', 'Z', '`', 'a', 'aj', 'aw', 'b', 'd', 'e', 'e~', 'f', 'g', 'i', 'i~', 'k', 'l', 'm', 'n', 'o', 'o~', 'p', 'r', 's', 't', 'u', 'u~', 'v', 'z'}
class voxpopuli.GreekPhonemes
AFFRICATES = {'dz', 'ts'}
CONSONANTS = {'C', 'D', 'G', 'T', 'b', 'c', 'd', 'dz', 'f', 'g', 'gj', 'j', 'jj', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'ts', 'v', 'x', 'z'}
FRICATIVES = {'D', 'G', 'T', 'f', 's', 'v', 'x', 'z'}
LIQUIDS = {'l', 'r'}
NASALS = {'m', 'n'}
PALATALS = {'C', 'c', 'gj', 'jj'}
PLOSIVES = {'b', 'd', 'g', 'k', 'p', 't'}
SEMIVOWEL = {'j'}
STRESSES = {'"', '%', "'", ':', '`'}
VOWELS = {' a', ' e', ' o', ' u', 'i'}
all = {' a', ' e', ' o', ' u', '"', '%', "'", ':', 'C', 'D', 'G', 'T', '`', 'b', 'c', 'd', 'dz', 'f', 'g', 'gj', 'i', 'j', 'jj', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'ts', 'v', 'x', 'z'}
class voxpopuli.ArabicPhonemes
CONSONANTS = {'?', '?`', 'D', 'D`', 'G', 'S', 'T', 'X\\', 'Z', 'b', 'd', 'd`', 'f', 'g', 'h', 'j', 'k', 'l', 'l`', 'm', 'n', 'p', 'q', 'r', 's', 's`', 't', 't`', 'v', 'w', 'x', 'z'}
FRICATIVES = {'?`', 'D', 'D`', 'G', 'S', 'T', 'X\\', 'Z', 'f', 'h', 's', 's`', 'v', 'x', 'z'}
LATERAL = {'l', 'l`'}
NASALS = {'m', 'n'}
PLOSIVES = {'?', 'b', 'd', 'd`', 'g', 'k', 'p', 'q', 't', 't`'}
SEMIVOWELS = {'j', 'w'}
STRESSES = {'"', '%', "'", ':', '`'}
TRILL = {'r'}
VOWELS = {'a', 'a:', 'i', 'i:', 'u', 'u:'}
all = {'"', '%', "'", ':', '?', '?`', 'D', 'D`', 'G', 'S', 'T', 'X\\', 'Z', '`', 'a', 'a:', 'b', 'd', 'd`', 'f', 'g', 'h', 'i', 'i:', 'j', 'k', 'l', 'l`', 'm', 'n', 'p', 'q', 'r', 's', 's`', 't', 't`', 'u', 'u:', 'v', 'w', 'x', 'z'}