Documentation
¶
Overview ¶
Package omniavatar provides a unified, provider-agnostic interface for AI avatars.
This is the batteries-included package that imports all providers. For a minimal dependency footprint, use github.com/plexusone/omniavatar-core instead.
Two surfaces are supported:
- live: real-time streaming avatar sessions (LiveKit rooms, PCM audio streaming for lip-sync) for conversational agents
- render: asynchronous batch avatar video generation (narration audio in, talking-head MP4 out) for offline pipelines such as presentation videos
Quick Start (live) ¶
import (
"github.com/plexusone/omniavatar"
_ "github.com/plexusone/omniavatar/providers/all"
)
func main() {
provider, err := omniavatar.GetLiveProvider("heygen",
omniavatar.WithAPIKey(os.Getenv("LIVEAVATAR_API_KEY")),
omniavatar.WithExtension("avatar_id", avatarID),
omniavatar.WithExtension("sandbox", true))
if err != nil {
log.Fatal(err)
}
session, err := provider.CreateSession(live.SessionConfig{
AudioConfig: live.DefaultAudioConfig(),
})
if err != nil {
log.Fatal(err)
}
// Use session with LiveKit or other platform adapters
}
Quick Start (render) ¶
provider, err := omniavatar.GetRenderProvider("heygen",
omniavatar.WithAPIKey(os.Getenv("HEYGEN_API_KEY")))
if err != nil {
log.Fatal(err)
}
job, err := provider.Generate(ctx, render.GenerateRequest{
AvatarID: avatarID,
AudioURL: narrationURL,
})
status, err := render.Wait(ctx, provider, job.ID, 5*time.Second)
err = provider.Download(ctx, job.ID, outFile)
Available Providers ¶
- heygen: HeyGen LiveAvatar (live) and HeyGen Video Generation (render)
- tavus: Tavus Conversational Video (live) and Video Generation (render)
- bithuman: bitHuman Real-time Avatars (live) and Video Generation (render, with audio upload support)
Architecture ¶
omniavatar follows the same pattern as omnivoice:
- omniavatar-core: Core interfaces (live, render) 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 GetLiveProvider(name string, opts ...ProviderOption) (live.Provider, error)
- func GetLiveProviderPriority(name string) int
- func GetRenderProvider(name string, opts ...ProviderOption) (render.Provider, error)
- func GetRenderProviderPriority(name string) int
- func HasLiveProvider(name string) bool
- func HasRenderProvider(name string) bool
- func ListLiveProviders() []string
- func ListRenderProviders() []string
- func RegisterLiveProvider(name string, factory LiveProviderFactory, priority int)
- func RegisterRenderProvider(name string, factory RenderProviderFactory, priority int)
- type AvatarMetadata
- type LiveKitStartOptions
- type LiveProviderFactory
- type ProviderConfig
- type ProviderOption
- type RenderProviderFactory
- 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 GetLiveProvider ¶ added in v0.2.0
func GetLiveProvider(name string, opts ...ProviderOption) (live.Provider, error)
GetLiveProvider creates a live provider instance from the registry. Returns an error if the provider is not registered or if creation fails.
Example:
provider, err := omniavatar.GetLiveProvider("heygen",
omniavatar.WithAPIKey(os.Getenv("LIVEAVATAR_API_KEY")),
omniavatar.WithExtension("avatar_id", avatarID))
func GetLiveProviderPriority ¶ added in v0.2.0
GetLiveProviderPriority returns the priority of the registered live provider. Returns -1 if the provider is not registered.
func GetRenderProvider ¶ added in v0.2.0
func GetRenderProvider(name string, opts ...ProviderOption) (render.Provider, error)
GetRenderProvider creates a render provider instance from the registry. Returns an error if the provider is not registered or if creation fails.
Example:
provider, err := omniavatar.GetRenderProvider("heygen",
omniavatar.WithAPIKey(os.Getenv("HEYGEN_API_KEY")))
func GetRenderProviderPriority ¶ added in v0.2.0
GetRenderProviderPriority returns the priority of the registered render provider. Returns -1 if the provider is not registered.
func HasLiveProvider ¶ added in v0.2.0
HasLiveProvider returns true if a live provider with the given name is registered.
func HasRenderProvider ¶ added in v0.2.0
HasRenderProvider returns true if a render provider with the given name is registered.
func ListLiveProviders ¶ added in v0.2.0
func ListLiveProviders() []string
ListLiveProviders returns a list of all registered live provider names.
func ListRenderProviders ¶ added in v0.2.0
func ListRenderProviders() []string
ListRenderProviders returns a list of all registered render provider names.
func RegisterLiveProvider ¶ added in v0.2.0
func RegisterLiveProvider(name string, factory LiveProviderFactory, priority int)
RegisterLiveProvider registers a live (real-time session) 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.RegisterLiveProvider("heygen", NewProviderFromConfig, omniavatar.PriorityThick)
}
func RegisterRenderProvider ¶ added in v0.2.0
func RegisterRenderProvider(name string, factory RenderProviderFactory, priority int)
RegisterRenderProvider registers a render (batch generation) 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.RegisterRenderProvider("heygen", NewRenderProviderFromConfig, 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 *live.SessionCallbacks
// AudioDestination is the audio output for streaming TTS audio.
// If provided, the session will use this instead of creating its own.
// Optional.
AudioDestination live.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 LiveProviderFactory ¶ added in v0.2.0
type LiveProviderFactory = registry.LiveProviderFactory
LiveProviderFactory creates a live.Provider from configuration.
type ProviderConfig ¶
type ProviderConfig = registry.ProviderConfig
ProviderConfig holds common configuration options for creating providers.
type ProviderOption ¶
type ProviderOption = registry.ProviderOption
ProviderOption configures a ProviderConfig.
type RenderProviderFactory ¶ added in v0.2.0
type RenderProviderFactory = registry.RenderProviderFactory
RenderProviderFactory creates a render.Provider from configuration.
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 |
|---|---|
|
examples
|
|
|
render-basic
command
Command render-basic generates a talking-head video from narration audio using any registered render provider.
|
Command render-basic generates a talking-head video from narration audio using any registered render provider. |
|
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. |