Skip to main content

Module voice

Module voice 

Source
Expand description

Shared voice/audio inbound transcription used by channel adapters.

Each platform exposes audio bytes differently (Telegram voice, Discord attachment, Slack file, Feishu audio message), but once we have raw bytes the dispatch into the configured STT provider — OpenAI Whisper or a local command — is the same. This module owns that dispatch and the format used when injecting transcription into the inbound text the agent sees.

Also exposes the inverse path: when a turn was triggered by an inbound voice message and voice_round_trip is enabled, channels call synth_speech_to_temp to render the bot’s reply as audio so the user can listen to it on the same surface they spoke into.

Functions§

can_transcribe
Returns true if a transcription provider is configured. Channels can use this to decide between transcribing or surfacing a “voice not supported” notice to the sender.
format_voice_inbound
Standard inbound formatting so the agent always sees voice messages with the same shape regardless of platform.
format_voice_inbound_error
Standard error shape when transcription was attempted but failed.
round_trip_enabled
True when this deployment should reply with audio to voice-inbound turns. Requires both the operator opt-in (voice_round_trip: true) and the TTS layer to be enabled in media.tts.
synth_speech_to_temp
Synthesize text to a temporary audio file using the configured TTS provider, returning the on-disk path. Caller is responsible for sending it to the user and removing the file when done.
transcribe_audio
Run audio bytes through the configured STT provider.