Documentation
¶
Overview ¶
Package heygen provides a HeyGen LiveAvatar provider for omniavatar.
HeyGen LiveAvatar enables real-time AI avatar video generation using the LITE mode, which integrates with LiveKit for audio streaming and video output.
Quick Start ¶
Import this package to auto-register the heygen provider:
import (
"github.com/plexusone/omniavatar"
_ "github.com/plexusone/omniavatar/providers/heygen"
)
func main() {
provider, err := omniavatar.GetAvatarProvider("heygen",
omniavatar.WithAPIKey(os.Getenv("HEYGEN_API_KEY")),
omniavatar.WithExtension("avatar_id", avatarID),
omniavatar.WithExtension("sandbox", true))
}
Configuration ¶
The heygen provider accepts the following extensions:
- avatar_id (string, required): UUID of the HeyGen avatar to use
- sandbox (bool, optional): Enable sandbox mode (60s limit, no credits)
- video_quality (string, optional): "very_high", "high", "medium", "low" (default: "high")
API Key ¶
Get your LiveAvatar API key from https://app.liveavatar.com/developers Note: This is different from the HeyGen video generation API key.
Index ¶
- func NewProviderFromConfig(cfg registry.ProviderConfig) (avatar.Provider, error)
- type Config
- type Provider
- type Session
- func (s *Session) AudioOutput() avatar.AudioDestination
- func (s *Session) Close(ctx context.Context) error
- 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) SessionID() string
- 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProviderFromConfig ¶
func NewProviderFromConfig(cfg registry.ProviderConfig) (avatar.Provider, error)
NewProviderFromConfig creates a HeyGen provider from registry config.
Types ¶
type Config ¶
type Config struct {
// APIKey is the LiveAvatar API key.
// Required.
APIKey string
// BaseURL is the LiveAvatar API base URL.
// Default: https://api.liveavatar.com
BaseURL string
// AvatarID is the UUID of the avatar to use.
// Use liveavatar.SandboxAvatarID for testing.
// Required.
AvatarID string
// Sandbox enables sandbox mode (60s limit, no credits).
// Recommended for development and testing.
Sandbox bool
// VideoQuality sets the avatar video quality.
// Options: "very_high", "high", "medium", "low"
// Default: "high"
VideoQuality string
}
Config configures the HeyGen LiveAvatar provider.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements avatar.Provider for HeyGen LiveAvatar.
func NewProvider ¶
NewProvider creates a new HeyGen LiveAvatar provider.
func (*Provider) CreateSession ¶
CreateSession creates a new HeyGen avatar session.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session implements avatar.Session for HeyGen LiveAvatar.
func NewSession ¶
func NewSession(cfg SessionConfig) (*Session, error)
NewSession creates a new HeyGen LiveAvatar session.
func (*Session) AudioOutput ¶
func (s *Session) AudioOutput() avatar.AudioDestination
AudioOutput returns the audio destination for streaming TTS audio.
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 LiveAvatar API client.
// Required.
Client *liveavatar.Client
// AvatarID is the UUID of the avatar to use.
// Required.
AvatarID string
// Sandbox enables sandbox mode.
Sandbox bool
// VideoQuality sets the avatar video quality.
VideoQuality liveavatar.VideoQuality
// AudioConfig configures the audio format.
AudioConfig avatar.AudioConfig
}
SessionConfig configures a HeyGen LiveAvatar session.