gowhisper

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 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

gowhisper implements an API client for go-whisper, which transcribes, and translates, speech with whisper.cpp models, which it downloads and stores. https://github.com/mutablelogic/go-whisper

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*client.Client
	// contains filtered or unexported fields
}

func New

func New(endPoint string, opts ...client.ClientOpt) (*Client, error)

New returns a client of a go-whisper server, with its endpoint, which should be something like "http://localhost:8081/api/whisper". An endpoint without a scheme, such as "localhost", uses http and go-whisper's default port, 8081, unless it has a port, and one without a path uses go-whisper's, "/api/whisper". go-whisper has no API key.

func (*Client) DeleteModel

func (c *Client) DeleteModel(ctx context.Context, model llm.Model) error

DeleteModel deletes the model, which must be a go-whisper model, from the server

func (*Client) GetModel

func (c *Client) GetModel(ctx context.Context, name string) (llm.Model, error)

GetModel returns the model with the name, which is its id, such as "ggml-medium-q5_0", or its file, such as "ggml-medium-q5_0.bin". Returns ErrNotFound when it isn't one of go-whisper's own models.

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context) ([]llm.Model, error)

ListModels returns go-whisper's own models, which it runs, rather than those of the services it forwards to, such as OpenAI and ElevenLabs

func (*Client) LoadModel

func (c *Client) LoadModel(ctx context.Context, name string, progress llm.DownloadProgressFn) (llm.Model, error)

LoadModel downloads the model with the name, which is its file, such as "ggml-tiny.en.bin", from the whisper.cpp models on Hugging Face, or its id, such as "ggml-tiny.en", and returns it, or returns it if it's already downloaded. Returns ErrNotFound when there's no such model to download. The progress function, if not nil, is called as it downloads, with the percentage of its bytes downloaded. The download isn't timed out, as models can be large, but is cancelled with the context.

func (*Client) Name

func (*Client) Name() string

Name returns the provider name

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks the server can be reached, by listing its models, as go-whisper has no version, and returns an error if it can't

func (*Client) Self

func (c *Client) Self() llm.Provider

Self returns the underlying client implementation

func (*Client) Transcribe

func (c *Client) Transcribe(ctx context.Context, model llm.Model, audio llm.Resource, stream llm.TranscriberStreamFn, opts ...llm.Opt) (llm.Transcript, llm.Usage, error)

Transcribe returns the speech in the audio as text, and its language, which the model detects, unless it's set, and its segments, when they're asked for, and the seconds of audio. When the stream function isn't nil, the transcript is streamed, each segment as it's transcribed. The request isn't timed out, as audio can take a while, but is cancelled with the context.

func (*Client) Translate

func (c *Client) Translate(ctx context.Context, model llm.Model, audio llm.Resource, stream llm.TranscriberStreamFn, opts ...llm.Opt) (llm.Transcript, llm.Usage, error)

Translate returns the speech in the audio, in any language, as English text, as Transcribe does. Returns ErrNotImplemented for an English-only model, which doesn't translate.

func (*Client) URL

func (c *Client) URL() *url.URL

URL returns the client's normalized endpoint

func (*Client) UnloadModel

func (c *Client) UnloadModel(ctx context.Context, model llm.Model) error

UnloadModel returns ErrNotImplemented, as go-whisper loads a model each time it's used

type Model

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

Model is a whisper.cpp model of a go-whisper server

func (*Model) Aliases

func (m *Model) Aliases() []string

Aliases returns the model's file, such as "ggml-medium-q5_0.bin", which it's downloaded by, when it's not its name

func (*Model) Capabilities

func (m *Model) Capabilities() llm.ModelCap

Capabilities returns what the model can do, which is transcribe speech, and translate it into English, unless it's an English-only model, whose name has ".en", such as "ggml-tiny.en", and nothing else

func (*Model) Created

func (m *Model) Created() time.Time

Created returns when the model was downloaded

func (*Model) Description

func (m *Model) Description() string

Description returns the model's file, such as "ggml-medium-q5_0.bin", as go-whisper has no description

func (*Model) InputTokenLimit

func (m *Model) InputTokenLimit() *uint

InputTokenLimit isn't known, as a whisper model transcribes audio

func (*Model) Meta

func (m *Model) Meta() map[string]json.RawMessage

Meta returns the model's file, and who owns it

func (*Model) Name

func (m *Model) Name() string

Name returns the model's id, such as "ggml-medium-q5_0"

func (*Model) OutputTokenLimit

func (m *Model) OutputTokenLimit() *uint

OutputTokenLimit isn't known, as a whisper model transcribes audio

func (*Model) Provider

func (m *Model) Provider() llm.Provider

Provider returns the client the model came from

Jump to

Keyboard shortcuts

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