API Reference

adafruit_moonshine_klatt

Text to speech for CircuitPython using the Moonshine Klatt formant synthesizer.

Software and Dependencies:

class adafruit_moonshine_klatt.TTS(audio)

Speak text through an audio output.

Parameters:

audio – An audio output object with play(), stop() and playing, such as audiobusio.I2SOut, audioio.AudioOut or audiopwmio.PWMAudioOut. The library creates its own audiomixer.Mixer on it. Or an audiomixer.MixerVoice from the caller’s mixer, whose sample rate must match sample_rate.

deinit() → None

Stop speaking and release the mixer this object created. The audio output and a caller’s mixer are not deinitialized; the caller owns them.

property pitch: float

Pitch multiplier, 1.0 is normal. Clamped to 0.5 to 2.0.

property rate: int

Speaking rate in words per minute. Default 150.

property sample_rate: int

Sample rate of the speech output in Hz.

say(text: str, *, wait: bool = True, interrupt: bool = False) → None

Speak text. If speech is already playing, text is queued after it.

Parameters:
  • text (str) – The text to speak.

  • wait (bool) – If True, return when all queued speech ends. If False, return right away; call update in the main loop to keep speech going.

  • interrupt (bool) – If True, stop current speech and clear the queue first.

property speaking: bool

True while speech is playing or queued.

stop() → None

Stop speaking and clear the queue.

update() → None

Render and queue the next chunk of speech when the mixer is ready for it. Call often from the main loop after say(..., wait=False).

property voice: str

Voice preset name. See voices for the ones available.

property voices: tuple

Voice preset names available.

property volume: float

Volume from 0.0 to 1.0, applied as the mixer voice level. Default 1.0.