Tavus
Video service implementation for generating AI avatar responses using Tavus
Overview
TavusVideoService
enables the creation of AI avatar video responses by sending audio to Tavus’s API. It handles real-time audio streaming, conversation management, and video generation through Tavus’s platform.
Installation
To use TavusVideoService
, install the required dependencies:
You’ll need to set up the following environment variables:
TAVUS_API_KEY
- Your Tavus API keyTAVUS_REPLICA_ID
- Your Tavus replica identifierTAVUS_PERSONA_ID
- (Optional) Your Tavus persona identifier
You can obtain a Tavus API key by signing up at Tavus.
Configuration
Constructor Parameters
Your Tavus API key
Tavus replica identifier
Tavus persona identifier
HTTP client session for API communication
Input Frames
Audio Input
Raw audio data for avatar speech
Control Frames
Signals start of speech synthesis
Signals end of speech synthesis
Signals conversation interruption
Signals end of conversation
Signals conversation cancellation
Usage Example
API Methods
initialize
Initializes a new conversation and returns the conversation URL.
get_persona_name
Retrieves the name of the configured persona.
Frame Flow
Metrics Support
The service collects processing metrics:
- Processing duration
- Time to First Byte (TTFB)
- API response times
- Audio processing metrics
Common Use Cases
-
AI Video Avatars
- Virtual assistants
- Customer service
- Educational content
-
Interactive Presentations
- Product demonstrations
- Training materials
- Marketing content
-
Real-time Communication
- Video conferencing
- Virtual meetings
- Interactive broadcasts
Notes
- Handles real-time audio streaming
- Supports conversation interruptions
- Manages conversation lifecycle
- Automatic audio resampling
- Thread-safe processing
- WebRTC integration through Daily
- Includes comprehensive error handling