Audio Control Module#

This module provides simple text-to-speech functionality for the dog robot. It wraps the underlying pyttsx3 engine and handles thread-safe playback.

class go2.modules.audio.audio_module.AudioModule[source]#

Bases: DogModule

AudioModule supports both blocking and asynchronous playback.

Users should not access or construct this class directly. Rather, they should access it through a Go2Controller instance.

Notes

  • Users do not need to manage threads or the underlying pyttsx3 engine. Though it can be done via a call AudioModule.get_engine().

get_engine() Engine[source]#

Access the underlying pyttsx3 engine.

Returns:

The initialized text-to-speech engine.

Return type:

pyttsx3.Engine

Raises:

RuntimeError – If the audio module has not been initialized yet.

Notes

This method is primarily for advanced use cases. Users typically do not need to call this directly. Unless they want to modify the configuration of the text-to-speech

play_audio(text: str, blocking=False) None[source]#

Play audio from text.

Parameters:
  • text (str) – The text string to be spoken by the robot.

  • blocking (bool, optional) – If True, the method blocks until the speech finishes. If False (default), playback occurs asynchronously in a background thread.