Using Voice with Agents
Giving your Agent a Voice
Timbal agents can be enhanced with voice capabilities, enabling them to speak and listen. This example demonstrates how to configure voice functionality for your agents.
Prerequisites
This example uses the openai
model. Make sure to add OPENAI_API_KEY
to your .env
file.
Voice Tools
Create TTS and STT tools that the agent can use to process audio input and generate audio responses:
Speech-to-Text Tool
Text-to-Speech Tool
Voice-Enabled Agent
Create an agent with voice tools that can read audio files and respond with audio:
Example usage
This example shows how the agent can process audio input and respond with audio:
Available voice handlers
Timbal provides several built-in voice handlers:
OpenAI Handlers
- STT:
timbal.handlers.openai.stt.stt
- OpenAI Integration - TTS:
timbal.handlers.openai.tts.tts
- OpenAI Integration
ElevenLabs Handler
- STT:
timbal.handlers.elevenlabs.stt.stt
- ElevenLabs Integration - TTS:
timbal.handlers.elevenlabs.tts.tts
- ElevenLabs Integration
Configuration
Make sure you have the required API keys set in your environment:
OPENAI_API_KEY
for OpenAI voice servicesELEVENLABS_API_KEY
for ElevenLabs services
The agent now has voice tools as part of its capabilities, making it truly voice-enabled!