Documentation
¶
Overview ¶
Package tavus provides a Tavus Conversational Video provider for omniavatar.
Tavus enables real-time AI avatar video generation that integrates with LiveKit for audio streaming and video output.
Quick Start ¶
Import this package to auto-register the tavus provider:
import (
"github.com/plexusone/omniavatar"
_ "github.com/plexusone/omniavatar/providers/tavus"
)
func main() {
provider, err := omniavatar.GetAvatarProvider("tavus",
omniavatar.WithAPIKey(os.Getenv("TAVUS_API_KEY")),
omniavatar.WithExtension("pal_id", palID))
}
Configuration ¶
The tavus provider accepts the following extensions:
- pal_id (string, optional): PAL (Personalized AI Likeness) ID. Defaults to stock avatar.
- face_id (string, optional): Face override ID.
API Key ¶
Get your Tavus API key from https://docs.tavus.io
Index ¶
- Constants
- func NewProviderFromConfig(cfg registry.ProviderConfig) (avatar.Provider, error)
- type Client
- type ClientConfig
- type Config
- type CreateConversationRequest
- type CreateConversationResponse
- type Provider
- type Session
- func (s *Session) AudioOutput() avatar.AudioDestination
- func (s *Session) Close(ctx context.Context) error
- func (s *Session) ConversationID() string
- func (s *Session) EmitError(err error)
- func (s *Session) EmitPlaybackFinished(position float64, interrupted bool)
- func (s *Session) EmitPlaybackStarted()
- func (s *Session) Identity() string
- func (s *Session) Provider() string
- func (s *Session) Room() *lksdk.Room
- func (s *Session) SetAudioOutput(out avatar.AudioDestination)
- func (s *Session) SetCallbacks(callbacks *avatar.SessionCallbacks)
- func (s *Session) Start(ctx context.Context, opts any) error
- func (s *Session) WaitForJoin(ctx context.Context, timeout time.Duration) error
- type SessionConfig
Constants ¶
const DefaultPalID = "pb87e71797da"
DefaultPalID is the stock Tavus PAL for testing.
Variables ¶
This section is empty.
Functions ¶
func NewProviderFromConfig ¶
func NewProviderFromConfig(cfg registry.ProviderConfig) (avatar.Provider, error)
NewProviderFromConfig creates a Tavus provider from registry config.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the tavus-go SDK for avatar session management.
func NewClient ¶
func NewClient(cfg ClientConfig) (*Client, error)
NewClient creates a new Tavus API client using the tavus-go SDK.
func (*Client) CreateConversation ¶
func (c *Client) CreateConversation(ctx context.Context, req CreateConversationRequest) (*CreateConversationResponse, error)
CreateConversation creates a new conversation with the Tavus API.
func (*Client) EndConversation ¶
EndConversation ends an active conversation.
type ClientConfig ¶
type ClientConfig struct {
// APIKey is the Tavus API key.
// Required.
APIKey string
// BaseURL is the Tavus API base URL.
// Default: https://tavusapi.com
BaseURL string
// HTTPClient is an optional custom HTTP client.
// Default: http.Client with 30s timeout
HTTPClient *http.Client
}
ClientConfig configures the Tavus API client.
type Config ¶
type Config struct {
// APIKey is the Tavus API key.
// Required.
APIKey string
// BaseURL is the Tavus API base URL.
// Default: https://tavusapi.com
BaseURL string
// PalID is the PAL (Personalized AI Likeness) to use.
// Default: stock avatar (DefaultPalID)
PalID string
// FaceID is an optional face override.
FaceID string
}
Config configures the Tavus avatar provider.
type CreateConversationRequest ¶
type CreateConversationRequest struct {
// PalID is the PAL (Personalized AI Likeness) to use.
// Required.
PalID string
// FaceID is an optional face override.
FaceID string
// LiveKitURL is the LiveKit WebSocket URL for the avatar to connect to.
LiveKitURL string
// LiveKitToken is the JWT token for the avatar to join the room.
LiveKitToken string
// ConversationName is an optional name for the conversation.
// Auto-generated if not provided.
ConversationName string
}
CreateConversationRequest is the request to create a conversation.
type CreateConversationResponse ¶
type CreateConversationResponse struct {
// ConversationID is the unique identifier for the conversation.
ConversationID string
// ConversationURL is the URL for the conversation (if available).
ConversationURL string
}
CreateConversationResponse is the response from creating a conversation.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements avatar.Provider for Tavus.
func NewProvider ¶
NewProvider creates a new Tavus avatar provider.
func (*Provider) CreateSession ¶
CreateSession creates a new Tavus avatar session.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session implements avatar.Session for Tavus avatars.
func NewSession ¶
func NewSession(cfg SessionConfig) (*Session, error)
NewSession creates a new Tavus avatar session.
func (*Session) AudioOutput ¶
func (s *Session) AudioOutput() avatar.AudioDestination
AudioOutput returns the audio destination for streaming TTS audio.
func (*Session) ConversationID ¶
ConversationID returns the Tavus conversation ID.
func (*Session) EmitPlaybackFinished ¶
EmitPlaybackFinished emits a playback finished event.
func (*Session) EmitPlaybackStarted ¶
func (s *Session) EmitPlaybackStarted()
EmitPlaybackStarted emits a playback started event.
func (*Session) SetAudioOutput ¶
func (s *Session) SetAudioOutput(out avatar.AudioDestination)
SetAudioOutput sets the audio destination.
func (*Session) SetCallbacks ¶
func (s *Session) SetCallbacks(callbacks *avatar.SessionCallbacks)
SetCallbacks registers event callbacks for the session.
type SessionConfig ¶
type SessionConfig struct {
// Client is the Tavus API client.
// Required.
Client *Client
// PalID is the PAL (Personalized AI Likeness) to use.
// Required.
PalID string
// FaceID is an optional face override.
FaceID string
// AudioConfig configures the audio format.
AudioConfig avatar.AudioConfig
}
SessionConfig configures a Tavus avatar session.