gallery

package
v0.5.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gallery is the data side of Discover voices: about 35 curated voices (thread #94, after #91's audit) with their use cases, facets, search, favorites, the Design page's starting-point presets, and (in package persona) the .asvoice voice-file format.

The curated voices come from data/curated.json: designed voices with a written persona (the description the model gets), a tested seed and a reference shipped with the app, and the built-in speakers worth offering. The earlier gallery (data/featured.json and data/roles.json: about 1,100 voices, mostly attribute combinations) is no longer listed, but its ids still resolve (ByID), so dub casts and agents that name one keep working; a voice saved from one carries its own recipe.

The earlier gallery (thread #94 stopped listing it): hand-made "featured" voices (data/featured.json) and use-case roles (data/roles.json) that expand combinatorially over gender × age × timbre "flavor" × accent/dialect/language "locale", filtered so no combination contradicts itself. IDs are derived from those parts, so they stay stable as long as the parts keep their ids. They still resolve (LegacyByID): dub casts and agents may name them.

Index

Constants

View Source
const (
	KindDesigned = "designed" // a persona, a seed and a bundled reference
	KindBuiltin  = "builtin"  // a model's built-in speaker
)

Kinds of curated voices (Archetype.Kind; "" = an earlier gallery voice).

View Source
const (
	DefaultLimit = 60
	MaxLimit     = 500
)

Page sizes.

View Source
const CuratedPrefix = "c-"

CuratedPrefix starts the ids of curated voices.

Variables

Facets lists the facets in display order (thread #94: pitch, accent and style went with the earlier gallery).

View Source
var Languages = []string{"zh", "en", "ja", "ko", "es", "fr", "de", "it", "pt", "ru", "hi"}

Languages lists the language facet: the languages voices speak, in display order.

Functions

func CategoryID

func CategoryID(id string) string

CategoryID is the use case a category id stands for: itself, or the use case an earlier gallery category maps to; "" when unknown.

Types

type Archetype

type Archetype struct {
	ID       string `json:"id"`
	Kind     string `json:"kind,omitempty"`
	Featured bool   `json:"featured,omitempty"`
	// Category is the first use case (curated) or the earlier gallery's
	// category; Uses are all of a curated voice's use cases.
	Category    string        `json:"category"`
	Uses        []string      `json:"uses,omitempty"`
	Role        string        `json:"role,omitempty"` // generated archetypes: the role id
	Name        vd.Text       `json:"name"`
	Description vd.Text       `json:"description"`
	Sample      vd.Text       `json:"sample"`          // preview line in English and Chinese (earlier gallery)
	Local       *LocalLine    `json:"local,omitempty"` // preview line for a language other than en/zh
	Attrs       vd.Attributes `json:"attrs"`
	Gender      string        `json:"gender,omitempty"` // facet value (vd.Gender)
	Age         string        `json:"age,omitempty"`    // facet value (vd.Age)
	Languages   []string      `json:"languages"`        // recommended, BCP-47; the first is the preview language
	Tags        []string      `json:"tags,omitempty"`
	Seed        int64         `json:"seed"`
	// Persona is a curated designed voice's description: what the design
	// model gets, as written (thread #91: the earlier gallery's own
	// descriptions were never sent). Line is what its preview says, in
	// its language; RefText what its bundled reference says.
	// RefGrade is the reference checker's grade of it ("good", "ok").
	Persona  string `json:"persona,omitempty"`
	Line     string `json:"line,omitempty"`
	RefText  string `json:"refText,omitempty"`
	RefGrade string `json:"refGrade,omitempty"`
	// Model (catalogue id) and Speaker: a curated built-in speaker.
	Model   string `json:"model,omitempty"`
	Speaker string `json:"speaker,omitempty"`
	// DesignModel is the catalogue id of the model that designed a
	// curated designed voice's reference and cloned its preview ("": Qwen3
	// 1.7B VoiceDesign and Base; Irodori-TTS for Japanese ones, #172).
	DesignModel string `json:"designModel,omitempty"`
	// Legacy marks a voice of the earlier gallery: found by id, not listed.
	Legacy bool `json:"legacy,omitempty"`
}

Archetype is one ready-made voice: a curated one, or one of the earlier gallery's (Legacy).

func BuildCurated

func BuildCurated() ([]Archetype, error)

BuildCurated reads the curated voices, in display order.

func BuildLegacy

func BuildLegacy() ([]Archetype, error)

BuildLegacy expands the earlier gallery's data into archetypes: featured first (hidden ones too: they resolve like the rest), then generated ones grouped by category in display order.

func LegacyByID

func LegacyByID(id string) (Archetype, bool)

LegacyByID finds a voice of the earlier gallery (built on first use, a few milliseconds), hidden ones too.

func (Archetype) Curated

func (a Archetype) Curated() bool

Curated reports whether a is one of the curated voices.

func (Archetype) Designed

func (a Archetype) Designed() bool

Designed reports whether a speaks through a design recipe (a curated designed voice, or any voice of the earlier gallery).

func (Archetype) PreviewLine

func (a Archetype) PreviewLine() (text, lang string)

PreviewLine is the text and language a preview of the archetype speaks: its first recommended language, with the matching line.

func (Archetype) Recipe

func (a Archetype) Recipe() vd.Recipe

Recipe is the voice as a design recipe ("Use voice" saves it as a designed voice profile): a curated voice's persona as written, with the attributes it says (so it is sent as it is) and its seed; an earlier gallery voice's attributes and seed. A built-in speaker has none.

type Category

type Category struct {
	ID          string  `json:"id"`
	Name        vd.Text `json:"name"`
	Description vd.Text `json:"description"`
}

Category is a use case of the gallery (the filter beside the search).

func Categories

func Categories() []Category

Categories lists the use cases in display order.

type Facet

type Facet string

Facet is a filter dimension of the gallery.

const (
	FacetCategory Facet = "category" // the use cases
	FacetGender   Facet = "gender"
	FacetAge      Facet = "age"
	FacetLanguage Facet = "language"
)

type FacetCount

type FacetCount struct {
	Value string  `json:"value"`
	Label vd.Text `json:"label"`
	Count int     `json:"count"`
}

FacetCount is one value of a facet with the number of results it would give (counted with every other filter applied).

func FacetValues

func FacetValues(f Facet) []FacetCount

FacetValues lists every value of a facet in display order (Count = 0), for building the filter UI before any search.

type FavoriteSet

type FavoriteSet interface{ Has(id string) bool }

FavoriteSet answers whether an id is a favorite (*Favorites implements it).

type FavoriteStore

type FavoriteStore interface {
	LoadFavorites(ctx context.Context) ([]string, error)
	SaveFavorite(ctx context.Context, id string, on bool) error
}

FavoriteStore persists favorites; the app implements it (e.g. on its settings or documents table). Keys are archetype ids, or later "community:<repo>:<id>" for community voices.

type Favorites

type Favorites struct {
	// contains filtered or unexported fields
}

Favorites is the in-memory favorites set, written through to a store. Has is cheap and safe to call from a build pass; Set does I/O and belongs on a goroutine.

func LoadFavorites

func LoadFavorites(ctx context.Context, store FavoriteStore) (*Favorites, error)

LoadFavorites reads the set from store (nil store = memory only).

func (*Favorites) Has

func (f *Favorites) Has(id string) bool

Has reports whether id is a favorite.

func (*Favorites) List

func (f *Favorites) List() []string

List returns the favorites, sorted.

func (*Favorites) Set

func (f *Favorites) Set(ctx context.Context, id string, on bool) error

Set marks or unmarks a favorite, persisting first; on a store error the set is unchanged.

func (*Favorites) Toggle

func (f *Favorites) Toggle(ctx context.Context, id string) (bool, error)

Toggle flips a favorite and returns the new state.

type Gallery struct {
	// contains filtered or unexported fields
}

Gallery is an immutable, searchable set of archetypes. It is safe for concurrent use.

func Default

func Default() *Gallery

Default returns the built-in gallery: the curated voices (built once, on first use). Its ByID also finds the earlier gallery's ids.

func New

func New(items []Archetype) (*Gallery, error)

New indexes archetypes after validating them: unique ids, known use cases, a persona, seed, preview line and reference text for a designed voice, a model and speaker for a built-in one (curated); valid attributes and a preview line (earlier gallery). Order is kept.

func (*Gallery) All

func (g *Gallery) All() []Archetype

All returns the archetypes listed, in display order (a copy).

func (*Gallery) ByID

func (g *Gallery) ByID(id string) (Archetype, bool)

ByID finds an archetype: a listed one, else (the built-in gallery) one of the earlier gallery's, which are not listed but still resolve.

func (*Gallery) Len

func (g *Gallery) Len() int

Len is the number of archetypes listed.

func (*Gallery) Search

func (g *Gallery) Search(q Query) Page

Search filters, counts facets and returns one page. Results keep the gallery's order.

type LocalLine

type LocalLine struct {
	Lang string `json:"lang"`
	Text string `json:"text"`
}

LocalLine is a sample line in another language.

type MemoryFavorites

type MemoryFavorites struct {
	Err error // returned by every call when set
	// contains filtered or unexported fields
}

MemoryFavorites is a FavoriteStore in memory (tests, previews).

func (*MemoryFavorites) LoadFavorites

func (m *MemoryFavorites) LoadFavorites(context.Context) ([]string, error)

func (*MemoryFavorites) SaveFavorite

func (m *MemoryFavorites) SaveFavorite(_ context.Context, id string, on bool) error

type Page

type Page struct {
	Items  []Archetype            `json:"items"`
	Total  int                    `json:"total"`  // matches across all pages
	Offset int                    `json:"offset"` // of Items[0]
	Next   int                    `json:"next"`   // offset of the next page, -1 = none
	Facets map[Facet][]FacetCount `json:"facets"` // values with Count > 0, in display order
}

Page is one page of results.

type Preset

type Preset struct {
	ID          string        `json:"id"`
	Icon        string        `json:"icon"` // semantic icon name for the UI ("book", "mic"…)
	Name        vd.Text       `json:"name"`
	Description vd.Text       `json:"description"`
	Attrs       vd.Attributes `json:"attrs"`
	StyleHint   vd.Text       `json:"styleHint"` // delivery instruction, for clones
	Script      vd.Text       `json:"script"`    // demo line
	Language    string        `json:"language"`  // the script's language for the demo ("en"/"zh")
	Demo        bool          `json:"demo,omitempty"`
	// Hidden presets are no longer offered (thread #94: 元气, 童声 and
	// 东北老铁 went; 耳语 and 冥想引导 became 轻声) but resolve by id, so
	// dub casts that name one keep their voice.
	Hidden bool `json:"hidden,omitempty"`
}

Preset is a starting point: on the Design page it replaces the recipe (Attrs, and Language for the script); on the Clone page its StyleHint is the delivery instruction for engines that take one. Demo presets also get a "hear demo" card with Script.

func PresetByID

func PresetByID(id string) (Preset, bool)

PresetByID finds a preset, hidden ones too.

func Presets

func Presets() []Preset

Presets lists the starting points offered, in display order.

func (Preset) Recipe

func (p Preset) Recipe(seed int64) vd.Recipe

Recipe is the preset as a design recipe with the given seed.

type Query

type Query struct {
	Text     string // every word must occur in the name, description, persona, tags or facets (en, zh or ja)
	Category string // a use case (or an earlier gallery category, mapped by CategoryID)
	Gender   string
	Age      string
	Language string // BCP-47 primary subtag among the recommended languages
	Featured bool   // featured archetypes only
	// Favorites restricts to favorites (FavoritesOnly) and is otherwise
	// unused; nil means no favorites.
	Favorites     FavoriteSet
	FavoritesOnly bool
	Offset        int
	Limit         int // 0 = DefaultLimit; capped at MaxLimit
}

Query filters and pages the gallery. Empty fields don't filter.

Directories

Path Synopsis
Package persona reads and writes .asvoice files: a portable voice (a cloned or designed voice profile) as one ZIP that carries its identity, recipe and engine parameters, licence, consent attestation, a preview clip, and optionally the reference clip and a portrait.
Package persona reads and writes .asvoice files: a portable voice (a cloned or designed voice profile) as one ZIP that carries its identity, recipe and engine parameters, licence, consent attestation, a preview clip, and optionally the reference clip and a portrait.

Jump to

Keyboard shortcuts

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