avatars

package
v0.226.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Angles = map[string]string{
	"three-quarter-left":  anglePrompt("a three-quarter view, head and shoulders turned about 45 degrees to their left"),
	"three-quarter-right": anglePrompt("a three-quarter view, head and shoulders turned about 45 degrees to their right"),
	"left-profile":        anglePrompt("a full side profile facing left"),
	"right-profile":       anglePrompt("a full side profile facing right"),
}

Angles maps each generatable view to the image-edit prompt that produces it from the front photo. Prompts ask for a neutral, closed mouth so the shots suit lip-sync models.

View Source
var DefaultAngles = []string{"three-quarter-left", "three-quarter-right"}

DefaultAngles are generated when the caller does not choose: the two three-quarter views hold identity better than full profiles.

View Source
var ImageExtensions = []string{".png", ".jpg", ".jpeg", ".webp"}

ImageExtensions are the portrait formats an avatar folder may hold.

Functions

func Delete

func Delete(dir, name string) error

Delete removes the named avatar folder and every image in it.

func Dir

func Dir() string

Dir returns the avatar library directory, ~/.infer/avatars.

func Names

func Names(dir string) []string

Names returns the names of the avatars in dir, for error hints.

Types

type Avatar

type Avatar struct {
	Name   string   `json:"name"`
	Images []string `json:"images"`
}

Avatar is one library entry. Images are the folder's portrait file names in sorted order; the first is the primary image lip-sync models receive.

func Create

func Create(ctx context.Context, dir, name, photo string, angles []string, edit EditFunc) (Avatar, error)

Create builds a new avatar folder dir/<name>/ from a front photo: the photo is stored as the primary image (01-front.<ext>), a JPEG upright and without metadata, and each angle is generated from that stored image concurrently with edit and saved as NN-<angle>.png in the order given. An existing avatar is never overwritten, and on any failure the half-built folder is removed.

func Get

func Get(dir, name string) (Avatar, error)

Get returns the named avatar from dir. The name must be a bare folder name: no absolute path, separators or "..", and not "." (the library itself). The check stays inline, in the shape the TTS input helper uses, so static analysis sees the name sanitized before it reaches the filesystem.

func List

func List(dir string) ([]Avatar, error)

List returns every avatar in dir that holds at least one image, sorted by name. A missing library is an empty one.

type EditFunc

type EditFunc func(ctx context.Context, prompt, imagePath string) (string, error)

EditFunc edits the image at imagePath with prompt and returns the path of the generated image file.

Jump to

Keyboard shortcuts

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