Documentation
¶
Overview ¶
Package omniavatar provides a unified, provider-agnostic interface for real-time AI avatars.
This is the batteries-included package that imports all providers. For a minimal dependency footprint, use github.com/plexusone/omniavatar-core instead.
Quick Start ¶
import (
"github.com/plexusone/omniavatar"
_ "github.com/plexusone/omniavatar/providers/all"
)
func main() {
provider, err := omniavatar.GetAvatarProvider("heygen",
omniavatar.WithAPIKey(os.Getenv("HEYGEN_API_KEY")),
omniavatar.WithExtension("avatar_id", avatarID),
omniavatar.WithExtension("sandbox", true))
if err != nil {
log.Fatal(err)
}
session, err := provider.CreateSession(avatar.SessionConfig{
AudioConfig: avatar.DefaultAudioConfig(),
})
if err != nil {
log.Fatal(err)
}
// Use session with LiveKit or other platform adapters
}
Available Providers ¶
- heygen: HeyGen LiveAvatar (LITE mode)
- tavus: Tavus Conversational Video
- bithuman: bitHuman Real-time Avatars
Architecture ¶
omniavatar follows the same pattern as omnivoice:
- omniavatar-core: Core interfaces with no provider dependencies
- omniavatar: Provider implementations with auto-registration
- omniavatar/providers/all: Convenience import for all providers
Index ¶
- Constants
- Variables
- func GenerateAvatarToken(opts TokenOptions) (string, error)
- func GetAvatarProvider(name string, opts ...ProviderOption) (avatar.Provider, error)
- func GetAvatarProviderPriority(name string) int
- func HasAvatarProvider(name string) bool
- func ListAvatarProviders() []string
- func RegisterAvatarProvider(name string, factory ProviderFactory, priority int)
- type AvatarMetadata
- type LiveKitStartOptions
- type ProviderConfig
- type ProviderFactory
- type ProviderOption
- type TokenOptions
Constants ¶
const ( // PriorityThin is the priority for thin (stdlib-only) provider implementations. // These have no external dependencies beyond the standard library. PriorityThin = 0 // PriorityThick is the priority for thick (official SDK) provider implementations. // These use official provider SDKs for full feature support. PriorityThick = 10 )
Priority constants for provider registration. Higher priority values override lower priority registrations.
Variables ¶
var ( WithAPIKey = registry.WithAPIKey WithBaseURL = registry.WithBaseURL WithExtension = registry.WithExtension )
Re-export option functions from omniavatar-core/registry.
Functions ¶
func GenerateAvatarToken ¶
func GenerateAvatarToken(opts TokenOptions) (string, error)
GenerateAvatarToken creates a JWT token for an avatar to join a room.
The token includes the special "lk.publish_on_behalf" attribute that allows the avatar participant to publish tracks that appear in the UI as if they came from the agent participant.
func GetAvatarProvider ¶
func GetAvatarProvider(name string, opts ...ProviderOption) (avatar.Provider, error)
GetAvatarProvider creates an avatar provider instance from the registry. Returns an error if the provider is not registered or if creation fails.
Example:
provider, err := omniavatar.GetAvatarProvider("heygen",
omniavatar.WithAPIKey(os.Getenv("HEYGEN_API_KEY")),
omniavatar.WithExtension("avatar_id", avatarID))
func GetAvatarProviderPriority ¶
GetAvatarProviderPriority returns the priority of the registered avatar provider. Returns -1 if the provider is not registered.
func HasAvatarProvider ¶
HasAvatarProvider returns true if an avatar provider with the given name is registered.
func ListAvatarProviders ¶
func ListAvatarProviders() []string
ListAvatarProviders returns a list of all registered avatar provider names.
func RegisterAvatarProvider ¶
func RegisterAvatarProvider(name string, factory ProviderFactory, priority int)
RegisterAvatarProvider registers an avatar provider factory with the given name and priority. Higher priority values override lower priority registrations.
Example:
// In omniavatar/providers/heygen/register.go (thick, priority 10)
func init() {
omniavatar.RegisterAvatarProvider("heygen", NewProviderFromConfig, omniavatar.PriorityThick)
}
Types ¶
type AvatarMetadata ¶
type AvatarMetadata struct {
// Kind identifies this as an avatar participant.
Kind string `json:"kind"`
// Provider is the avatar provider name.
Provider string `json:"provider,omitempty"`
// AgentIdentity is the identity of the agent this avatar represents.
AgentIdentity string `json:"agent_identity,omitempty"`
}
AvatarMetadata is the standard metadata structure for avatar participants.
func DefaultAvatarMetadata ¶
func DefaultAvatarMetadata(provider, agentIdentity string) AvatarMetadata
DefaultAvatarMetadata returns the default metadata for avatar participants.
type LiveKitStartOptions ¶
type LiveKitStartOptions struct {
// Room is the LiveKit room the agent has joined.
// Required.
Room *lksdk.Room
// AgentIdentity is the identity of the agent participant.
// The avatar will publish tracks on behalf of this identity
// using the lk.publish_on_behalf attribute.
// Required.
AgentIdentity string
// LiveKitURL is the LiveKit server URL for the avatar to connect to.
// This should match the URL the agent connected to.
// Required.
LiveKitURL string
// LiveKitAPIKey is used to generate tokens for the avatar.
// Required.
LiveKitAPIKey string
// LiveKitAPISecret is used to generate tokens for the avatar.
// Required.
LiveKitAPISecret string
// Callbacks configures optional event callbacks.
Callbacks *avatar.SessionCallbacks
// AudioDestination is the audio output for streaming TTS audio.
// If provided, the session will use this instead of creating its own.
// Optional.
AudioDestination avatar.AudioDestination
}
LiveKitStartOptions contains LiveKit-specific start options for avatar sessions.
This is passed to Session.Start() when integrating with LiveKit.
func (*LiveKitStartOptions) Validate ¶
func (o *LiveKitStartOptions) Validate() error
Validate checks that all required fields are set.
type ProviderConfig ¶
type ProviderConfig = registry.ProviderConfig
ProviderConfig holds common configuration options for creating providers.
type ProviderFactory ¶
type ProviderFactory = registry.ProviderFactory
ProviderFactory creates a Provider from configuration.
type ProviderOption ¶
type ProviderOption = registry.ProviderOption
ProviderOption configures a ProviderConfig.
type TokenOptions ¶
type TokenOptions struct {
// APIKey is the LiveKit API key.
// Required.
APIKey string
// APISecret is the LiveKit API secret.
// Required.
APISecret string
// RoomName is the room the avatar will join.
// Required.
RoomName string
// AvatarIdentity is the participant identity for the avatar.
// Required.
AvatarIdentity string
// AvatarName is the display name for the avatar participant.
// Optional, defaults to AvatarIdentity.
AvatarName string
// PublishOnBehalf is the identity of the agent participant.
// The avatar will publish tracks that appear as if they're from this participant.
// Required.
PublishOnBehalf string
// TTL is the token validity duration.
// Default: 5 minutes
TTL time.Duration
// Metadata is optional participant metadata.
Metadata string
}
TokenOptions configures avatar token generation.
Directories
¶
| Path | Synopsis |
|---|---|
|
providers
|
|
|
all
Package all imports all avatar providers for side-effect registration.
|
Package all imports all avatar providers for side-effect registration. |
|
bithuman
Package bithuman provides a bitHuman Real-time Avatars provider for omniavatar.
|
Package bithuman provides a bitHuman Real-time Avatars provider for omniavatar. |
|
heygen
Package heygen provides a HeyGen LiveAvatar provider for omniavatar.
|
Package heygen provides a HeyGen LiveAvatar provider for omniavatar. |
|
tavus
Package tavus provides a Tavus Conversational Video provider for omniavatar.
|
Package tavus provides a Tavus Conversational Video provider for omniavatar. |