catalogfile

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 9 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 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

View Source
var ErrInvalid = errors.New("invalid model catalog")

ErrInvalid reports input or a manifest that breaks the catalog's invariants.

View Source
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 Generate

func Generate(r io.Reader) ([]byte, error)

Generate reads `speech models --json` output and returns the manifest bytes.

func MarshalInput

func MarshalInput(in Input) ([]byte, error)

MarshalInput encodes in as indented JSON ending in a newline.

func Validate

func Validate(m Manifest) error

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.

func ReadInput

func ReadInput(r io.Reader) (Input, error)

ReadInput decodes `speech models --json` output, refusing unknown members.

func Strip

func Strip(in Input) Input

Strip returns a copy of in without its machine-local state.

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.

func Decode

func Decode(data []byte) (Manifest, error)

Decode reads manifest bytes and validates them.

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.

Jump to

Keyboard shortcuts

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