Versions in this module Expand all Collapse all v0 v0.11.3 Dec 1, 2026 Changes in this version + var ErrCancelled = errors.New("speech: cancelled") + var ErrClosed = errors.New("speech: object is closed") + var ErrDevice = errors.New("speech: device") + var ErrIO = errors.New("speech: io") + var ErrInternal = errors.New("speech: internal") + var ErrInvalidArgument = errors.New("speech: invalid_argument") + var ErrModelFile = errors.New("speech: model_file") + var ErrNotLoaded = errors.New("speech: libspeech is not loaded (call speech.Load first)") + var ErrOutOfMemory = errors.New("speech: out_of_memory") + var ErrOutOfRange = errors.New("speech: out_of_range") + var ErrUnsupported = errors.New("speech: unsupported") + func APIVersion() (major, minor int, err error) + func DeviceCount() int + func DeviceDescription(index int) (string, bool) + func DeviceMemory(index int) (total, free uint64, err error) + func DeviceName(index int) (string, bool) + func FreeAll() + func LibraryPath() string + func Load(path string) error + func Loaded() bool + func LoadedModels() int + func MakeVoice(modelPath, referencePath, voicePath string, params *LoadParams) error + func MakeVoiceFrom(modelPath string, voice *VoiceParams, voicePath string, params *LoadParams) error + func OptionCount() int + func Quantize(modelPath, typ, outPath string) error + func SetLogHandler(fn LogFunc) error + func StatusName(s Status) (string, bool) + func Version() (string, error) + type AudioFunc func(samples []float32) Control + type Control int32 + const Continue + const Stop + type Detection struct + func (d *Detection) Close() + func (d *Detection) End() error + func (d *Detection) Ending() (ending bool, end float64) + func (d *Detection) Push(samples []float32) error + func (d *Detection) Region(index int) (Region, error) + func (d *Detection) RegionCount() int + func (d *Detection) Regions() ([]Region, error) + func (d *Detection) Speaking() (speaking bool, start float64, kept bool) + type Device struct + Description string + FreeMemory uint64 + Index int + Kind DeviceKind + Name string + TotalMemory uint64 + func Devices() ([]Device, error) + type DeviceKind int32 + const DeviceCPU + const DeviceGPU + const DeviceIGPU + func DeviceKindOf(index int) (DeviceKind, error) + func (k DeviceKind) String() string + type Dialogue struct + func (d *Dialogue) Close() + func (d *Dialogue) End() error + func (d *Dialogue) Push(samples []float32) error + type DialogueFunc func(samples []float32, text string) Control + type Diarization struct + func (d *Diarization) Close() + func (d *Diarization) End() error + func (d *Diarization) Push(samples []float32) error + func (d *Diarization) Segment(index int) (Segment, error) + func (d *Diarization) SegmentCount() int + func (d *Diarization) Segments() ([]Segment, error) + func (d *Diarization) Settled() float64 + func (d *Diarization) Speaking(speaker int) (speaking bool, start float64) + type Enhancement struct + func (e *Enhancement) Close() + func (e *Enhancement) End() error + func (e *Enhancement) Push(samples []float32) error + type Error struct + Message string + Name string + Op string + Option string + Status Status + func (e *Error) Error() string + func (e *Error) Unwrap() error + type LoadParams struct + Device string + Threads int + Warmup bool + type LogFunc func(level LogLevel, text string) + type LogLevel int32 + const LogDebug + const LogError + const LogInfo + const LogWarn + func (l LogLevel) String() string + type MetaEntry struct + Key string + Value string + type Model struct + func LoadModel(path string, params *LoadParams) (*Model, error) + func (m *Model) AddVoice(name, path string) error + func (m *Model) Close() + func (m *Model) Info() (*ModelInfo, error) + func (m *Model) NewRequest() (*Request, error) + func (m *Model) Path() string + type ModelInfo struct + func OpenModelInfo(path string) (*ModelInfo, error) + func (mi *ModelInfo) Architecture() string + func (mi *ModelInfo) Basename() string + func (mi *ModelInfo) Close() + func (mi *ModelInfo) Device() (string, bool) + func (mi *ModelInfo) FileBytes() uint64 + func (mi *ModelInfo) Finetune() (string, bool) + func (mi *ModelInfo) FrameSamples() int + func (mi *ModelInfo) Incremental() bool + func (mi *ModelInfo) JSON() string + func (mi *ModelInfo) Language(index int) (string, bool) + func (mi *ModelInfo) LanguageCount() int + func (mi *ModelInfo) Languages() []string + func (mi *ModelInfo) Layout() uint32 + func (mi *ModelInfo) License() string + func (mi *ModelInfo) MaxTextTokens() int + func (mi *ModelInfo) Meta() []MetaEntry + func (mi *ModelInfo) MetaCount() int + func (mi *ModelInfo) MetaKey(index int) (string, bool) + func (mi *ModelInfo) MetaValue(index int) (string, bool) + func (mi *ModelInfo) Name() string + func (mi *ModelInfo) OptionAt(index int) Option + func (mi *ModelInfo) OptionChoice(o Option, index int) (string, bool) + func (mi *ModelInfo) OptionChoiceCount(o Option) int + func (mi *ModelInfo) OptionChoices(o Option) []string + func (mi *ModelInfo) OptionCount() int + func (mi *ModelInfo) OptionDefaultBool(o Option) (bool, error) + func (mi *ModelInfo) OptionDefaultFloat(o Option) (float64, error) + func (mi *ModelInfo) OptionDefaultInt(o Option) (int64, error) + func (mi *ModelInfo) OptionDefaultString(o Option) (string, error) + func (mi *ModelInfo) OptionHasDefault(o Option) bool + func (mi *ModelInfo) OptionRange(o Option) (Range, error) + func (mi *ModelInfo) OptionRequired(o Option) bool + func (mi *ModelInfo) OptionSteers(o Option) bool + func (mi *ModelInfo) Options() []Option + func (mi *ModelInfo) Organization() string + func (mi *ModelInfo) SampleRate() int + func (mi *ModelInfo) SizeLabel() string + func (mi *ModelInfo) Source() (repository, revision string, err error) + func (mi *ModelInfo) Speakers() int + func (mi *ModelInfo) Takes(o Option) bool + func (mi *ModelInfo) Task() Task + func (mi *ModelInfo) TextTokens(text string) (int, error) + func (mi *ModelInfo) Threads() int + func (mi *ModelInfo) Version() (string, bool) + func (mi *ModelInfo) VoiceCodec() (string, bool) + func (mi *ModelInfo) VoiceCount() int + func (mi *ModelInfo) VoiceDescription(index int) (string, bool) + func (mi *ModelInfo) VoiceFiles() bool + func (mi *ModelInfo) VoiceGender(index int) (string, bool) + func (mi *ModelInfo) VoiceLanguage(index int) (string, bool) + func (mi *ModelInfo) VoiceName(index int) (string, bool) + func (mi *ModelInfo) VoiceRecordings() bool + func (mi *ModelInfo) Voices() []Voice + func (mi *ModelInfo) WeightBytes() uint64 + func (mi *ModelInfo) WeightType() string + type Option int32 + const OptionBackchannel + const OptionBwe + const OptionCfgGuidanceMode + const OptionCfgMaxT + const OptionCfgMinT + const OptionCfgScaleInstructions + const OptionCfgScaleSpeaker + const OptionCfgScaleText + const OptionChunkLen + const OptionChunkRightContext + const OptionChunkSizeInSeconds + const OptionCodePredictorDoSample + const OptionCodePredictorTemperature + const OptionCodePredictorTopK + const OptionCodePredictorTopP + const OptionDecodeOnCpu + const OptionDecoding + const OptionDoSample + const OptionDraft + const OptionDurationScale + const OptionEopBias + const OptionExpertsOnCpu + const OptionFifoLen + const OptionGender + const OptionGuidanceScale + const OptionHopLengthPortion + const OptionInstructions + const OptionKeepTail + const OptionKeywords + const OptionKeywordsAlpha + const OptionKeywordsGuard + const OptionLanguage + const OptionMaxSeconds + const OptionMaxSpeechDurationS + const OptionMinDurationOff + const OptionMinDurationOn + const OptionMinSilenceDurationMs + const OptionMinSpeechDurationMs + const OptionName + const OptionOffset + const OptionOnset + const OptionOtherName + const OptionPadOffset + const OptionPadOnset + const OptionPersona + const OptionPrompt + const OptionRelationship + const OptionRepetitionPenalty + const OptionRescaleK + const OptionRescaleSigma + const OptionSeconds + const OptionSeed + const OptionSituation + const OptionSpeakFirst + const OptionSpeakerKvMaxLayers + const OptionSpeakerKvMinT + const OptionSpeakerKvScale + const OptionSpeakerUncondMode + const OptionSpeakers + const OptionSpeechPadMs + const OptionSpeed + const OptionSpkcacheLen + const OptionSpkcacheUpdatePeriod + const OptionSteps + const OptionStreamingMode + const OptionSwayCoeff + const OptionTailMeanThreshold + const OptionTailStdThreshold + const OptionTailWindowSize + const OptionTemperature + const OptionThreshold + const OptionTimestamps + const OptionTopK + const OptionTopP + const OptionTruncationFactor + const OptionVoice + func OptionFromName(name string) (Option, error) + func Options() []Option + func (o Option) Name() (string, bool) + func (o Option) String() string + func (o Option) Type() Type + type ProgressFunc func(done float64) Control + type Range struct + Max float64 + Min float64 + MinExclusive bool + func (r Range) Contains(v float64) bool + type Region struct + End float64 + Start float64 + type Request struct + func (r *Request) Cancel() + func (r *Request) Close() + func (r *Request) Detect() error + func (r *Request) Diarize() error + func (r *Request) Enhance(onAudio AudioFunc) error + func (r *Request) Model() *Model + func (r *Request) Result() (*Result, bool) + func (r *Request) SetAudio(samples []float32, sampleRate int) error + func (r *Request) SetBool(o Option, value bool) error + func (r *Request) SetFloat(o Option, value float64) error + func (r *Request) SetInt(o Option, value int64) error + func (r *Request) SetProgress(fn ProgressFunc) error + func (r *Request) SetString(o Option, value string) error + func (r *Request) SetText(text string) error + func (r *Request) StartDetection(sampleRate int) (*Detection, error) + func (r *Request) StartDialogue(sampleRate int, onFrame DialogueFunc) (*Dialogue, error) + func (r *Request) StartDiarization(sampleRate int) (*Diarization, error) + func (r *Request) StartEnhancement(sampleRate int, onAudio AudioFunc) (*Enhancement, error) + func (r *Request) Synthesize(onAudio AudioFunc) error + func (r *Request) Transcribe() error + type Result struct + func (res *Result) Language(index int) (string, bool) + func (res *Result) LanguageCount() int + func (res *Result) Languages() []string + func (res *Result) Samples() uint64 + func (res *Result) Seed() int64 + func (res *Result) Segment(index int) (Segment, error) + func (res *Result) SegmentCount() int + func (res *Result) SegmentSpeaker(index int) int + func (res *Result) Segments() ([]Segment, error) + func (res *Result) Stop() StopReason + func (res *Result) Text() (string, bool) + func (res *Result) Token(index int) (Token, error) + func (res *Result) TokenCount() int + func (res *Result) Tokens() ([]Token, error) + func (res *Result) Untimed() (string, bool) + type Segment struct + End float64 + Speaker int + Start float64 + Text string + type Status int32 + const StatusCancelled + const StatusDevice + const StatusIO + const StatusInternal + const StatusInvalidArgument + const StatusModelFile + const StatusOK + const StatusOutOfMemory + const StatusOutOfRange + const StatusUnsupported + func (s Status) String() string + type StopReason int32 + const StopCancelled + const StopComplete + const StopMaxSeconds + const StopModelLimit + func (s StopReason) Name() (string, bool) + func (s StopReason) String() string + type Task int32 + const TaskDetection + const TaskDialogue + const TaskDiarization + const TaskEnhancement + const TaskRecognition + const TaskSynthesis + func (t Task) String() string + type Token struct + End float64 + Start float64 + Text string + type Type int32 + const TypeBool + const TypeFloat + const TypeInt + const TypeString + func (t Type) String() string + type Voice struct + Description string + Gender string + Language string + Name string + type VoiceParams struct + func NewVoiceParams() (*VoiceParams, error) + func (vp *VoiceParams) AddReference(path string) error + func (vp *VoiceParams) AddVoice(path string) error + func (vp *VoiceParams) Close() + func (vp *VoiceParams) KeepLoudness() error + func (vp *VoiceParams) SetEmbedding(values []float32, tokens, dim int) error + func (vp *VoiceParams) SetLoudness(lufs float64) error + func (vp *VoiceParams) SetSpeaker(speaker int) error + func (vp *VoiceParams) SetTranscript(text string) error