Overview
TheUnmuteHandler class is the core component of the Unmute system that manages the complete voice conversation pipeline. It inherits from AsyncStreamHandler and coordinates audio streaming, speech recognition, language model generation, and text-to-speech synthesis.
Class Definition
Constructor
- input_sample_rate: 24000 Hz
- output_frame_size: 480 samples
- output_sample_rate: 24000 Hz
Properties
stt
SpeechToText | None
tts
TextToSpeech | None
Core Methods
receive
tuple[int, np.ndarray]
required
Audio frame tuple containing sample rate and mono audio array
- Sends audio to STT for transcription
- Detects pauses in user speech
- Handles bot interruptions
- Manages conversation state transitions
emit
tuple[int, np.ndarray] | AdditionalOutputs | ora.ServerEvent | CloseStream | None
start_up
cleanup
Conversation Management
add_chat_message_delta
str
required
Text to add to the current message
Literal['user', 'assistant']
required
Role of the message sender
int | None
Index of the message being generated (to avoid race conditions)
bool - True if this created a new message, False if appended to existing
interrupt_bot
RuntimeError if called when conversation state is not “bot_speaking”
update_session
ora.SessionConfig
required
Session configuration object
Utility Methods
audio_received_sec
float - Seconds of audio received
get_gradio_update
AdditionalOutputs containing GradioUpdate with:
chat_history: List of message dictionariesdebug_dict: Debug information dictionarydebug_plot_data: Plot data for visualizations
copy
UnmuteHandler
Internal Methods
determine_pause
bool - True if pause detected
detect_long_silence
check_for_bot_goodbye
Configuration Constants
Example Usage
Notes
- The handler uses a quest manager system to coordinate async tasks for STT, TTS, and LLM
- Conversation state is managed through the internal
Chatbotinstance - Audio is processed at 24kHz sample rate with mono channel
- The handler supports echo cancellation and VAD-based interruption detection