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 ¶
- type Client
- func (c *Client) DeleteModel(ctx context.Context, model llm.Model) error
- func (c *Client) GetModel(ctx context.Context, name string) (llm.Model, error)
- func (c *Client) ListModels(ctx context.Context) ([]llm.Model, error)
- func (c *Client) LoadModel(ctx context.Context, name string, progress llm.DownloadProgressFn) (llm.Model, error)
- func (*Client) Name() string
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Self() llm.Provider
- func (c *Client) Transcribe(ctx context.Context, model llm.Model, audio llm.Resource, ...) (llm.Transcript, llm.Usage, error)
- func (c *Client) Translate(ctx context.Context, model llm.Model, audio llm.Resource, ...) (llm.Transcript, llm.Usage, error)
- func (c *Client) URL() *url.URL
- func (c *Client) UnloadModel(ctx context.Context, model llm.Model) error
- type Model
- func (m *Model) Aliases() []string
- func (m *Model) Capabilities() llm.ModelCap
- func (m *Model) Created() time.Time
- func (m *Model) Description() string
- func (m *Model) InputTokenLimit() *uint
- func (m *Model) Meta() map[string]json.RawMessage
- func (m *Model) Name() string
- func (m *Model) OutputTokenLimit() *uint
- func (m *Model) Provider() llm.Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func New ¶
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 ¶
DeleteModel deletes the model, which must be a go-whisper model, from the server
func (*Client) GetModel ¶
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 ¶
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) Ping ¶
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) 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.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is a whisper.cpp model of a go-whisper server
func (*Model) Aliases ¶
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 ¶
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) Description ¶
Description returns the model's file, such as "ggml-medium-q5_0.bin", as go-whisper has no description
func (*Model) InputTokenLimit ¶
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) OutputTokenLimit ¶
OutputTokenLimit isn't known, as a whisper model transcribes audio