Documentation
¶
Overview ¶
Package catalogfile turns the output of speech.cpp's `speech models --json` into the model manifest embedded by pkg/download/catalog, and reads that manifest back.
The input's machine-local state (the model directory, each file's path, fetched flag and partial byte count, and the old files) never reaches the manifest. An input member this package does not know fails the generator, so a new field of a later speech.cpp release is a decision, not a silent drop.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("invalid model catalog")
ErrInvalid reports input or a manifest that breaks the catalog's invariants.
var Tasks = []string{"synthesis", "recognition", "detection", "diarization", "enhancement", "dialogue"}
Tasks lists the tasks a catalog model may have, as speech.cpp names them.
Functions ¶
func MarshalInput ¶
MarshalInput encodes in as indented JSON ending in a newline.
func Validate ¶
Validate checks the invariants every manifest keeps: a release version; unique model names and file names; a known task; a 40-hex revision; per model unique weight types including the default one; and per file a positive size, a lowercase SHA-256 and the URL https://huggingface.co/<repository>/resolve/<revision>/<file>.
Types ¶
type File ¶
type File struct {
Type string `json:"type"`
Name string `json:"name"`
URL string `json:"url"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
}
File is one weight file of Model.
type Input ¶
type Input struct {
Version string `json:"version"`
Directory string `json:"directory,omitzero"`
Models []InputModel `json:"models"`
Old []json.RawMessage `json:"old,omitzero"`
}
Input is the document `speech models --json` prints.
type InputFile ¶
type InputFile struct {
Type string `json:"type"`
File string `json:"file"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
URL string `json:"url"`
Path string `json:"path,omitzero"`
Fetched bool `json:"fetched,omitzero"`
Partial int64 `json:"partial,omitzero"`
}
InputFile is one weight file of InputModel.
type InputModel ¶
type InputModel struct {
Name string `json:"name"`
Repository string `json:"repository"`
Revision string `json:"revision"`
Task string `json:"task"`
Languages []string `json:"languages"`
VoiceFiles bool `json:"voice_files"`
Start []string `json:"start"`
Type string `json:"type"`
Files []InputFile `json:"files"`
}
InputModel is one model of Input.
type Manifest ¶
type Manifest struct {
SpeechCppVersion string `json:"speech_cpp_version"`
Models []Model `json:"models"`
}
Manifest is the embedded model catalog.
type Model ¶
type Model struct {
Name string `json:"name"`
Task string `json:"task"`
Repository string `json:"repository"`
Revision string `json:"revision"`
Languages []string `json:"languages"`
StartLanguages []string `json:"start_languages"`
VoiceFiles bool `json:"voice_files"`
DefaultType string `json:"default_type"`
Files []File `json:"files"`
}
Model is one catalog model of Manifest.