heygen

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 11 Imported by: 0

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

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

func NewProvider(cfg Config) (*Provider, error)

NewProvider creates a new HeyGen LiveAvatar provider.

func (*Provider) CreateSession

func (p *Provider) CreateSession(cfg avatar.SessionConfig) (avatar.Session, error)

CreateSession creates a new HeyGen avatar session.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

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) Close

func (s *Session) Close(ctx context.Context) error

Close disconnects the avatar and cleans up resources.

func (*Session) EmitError

func (s *Session) EmitError(err error)

EmitError emits an error event.

func (*Session) EmitPlaybackFinished

func (s *Session) EmitPlaybackFinished(position float64, interrupted bool)

EmitPlaybackFinished emits a playback finished event.

func (*Session) EmitPlaybackStarted

func (s *Session) EmitPlaybackStarted()

EmitPlaybackStarted emits a playback started event.

func (*Session) Identity

func (s *Session) Identity() string

Identity returns the avatar participant identity.

func (*Session) Provider

func (s *Session) Provider() string

Provider returns the provider name.

func (*Session) Room

func (s *Session) Room() *lksdk.Room

Room returns the LiveKit room reference.

func (*Session) SessionID

func (s *Session) SessionID() string

SessionID returns the LiveAvatar session ID.

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.

func (*Session) Start

func (s *Session) Start(ctx context.Context, opts any) error

Start initializes the HeyGen LiveAvatar session.

The opts parameter must be *omniavatar.LiveKitStartOptions.

func (*Session) WaitForJoin

func (s *Session) WaitForJoin(ctx context.Context, timeout time.Duration) error

WaitForJoin blocks until the avatar participant joins the room.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL