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 ¶
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).
const ( DefaultLimit = 60 MaxLimit = 500 )
Page sizes.
const CuratedPrefix = "c-"
CuratedPrefix starts the ids of curated voices.
Variables ¶
var Facets = []Facet{FacetCategory, FacetGender, FacetAge, FacetLanguage}
Facets lists the facets in display order (thread #94: pitch, accent and style went with the earlier gallery).
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 ¶
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 ¶
BuildCurated reads the curated voices, in display order.
func BuildLegacy ¶
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 ¶
LegacyByID finds a voice of the earlier gallery (built on first use, a few milliseconds), hidden ones too.
func (Archetype) Designed ¶
Designed reports whether a speaks through a design recipe (a curated designed voice, or any voice of the earlier gallery).
func (Archetype) PreviewLine ¶
PreviewLine is the text and language a preview of the archetype speaks: its first recommended language, with the matching line.
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).
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 ¶
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).
type Gallery ¶
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 ¶
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.
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 ¶
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 ¶
PresetByID finds a preset, hidden ones too.
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.
Source Files
¶
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. |