whisper

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SampleRate = whisper.SampleRate
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	*whisper.Context
	// contains filtered or unexported fields
}

func NewContextWithModel

func NewContextWithModel(base string, model *Model) *Context

func (*Context) Close

func (c *Context) Close() error

func (*Context) Params

func (c *Context) Params() *whisper.Params

func (*Context) SetLanguage

func (c *Context) SetLanguage(v string) error

func (*Context) SetPrompt added in v0.0.3

func (c *Context) SetPrompt(v string)

func (*Context) SetTemperature added in v0.0.3

func (c *Context) SetTemperature(v float32)

func (*Context) SetTranslate

func (c *Context) SetTranslate(v bool)

type Model

type Model struct {
	Id      string `json:"id"`
	Object  string `json:"object"`
	Path    string `json:"path,omitempty"`
	Created int64  `json:"created,omitempty"`
	OwnedBy string `json:"owned_by,omitempty"`
}

type ModelPool

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

func NewModelPool

func NewModelPool(path string, model *Model) *ModelPool

func (*ModelPool) Close

func (m *ModelPool) Close() error

func (*ModelPool) Get

func (m *ModelPool) Get() *Context

Returns a newly loaded model context, or nil if there is an error

func (*ModelPool) N

func (m *ModelPool) N() int

Return the number of contexts in the pool

func (*ModelPool) Put

func (m *ModelPool) Put(ctx *Context)

Puts the context back in the pool

type Transcription

type Transcription struct {
	Task     string                 `json:"task,omitempty"`
	Language string                 `json:"language,omitempty"`
	Duration float64                `json:"duration,omitempty"`
	Text     string                 `json:"text"`
	Segments []TranscriptionSegment `json:"segments,omitempty"`
}

type TranscriptionSegment

type TranscriptionSegment struct {
	Id    int     `json:"id"`
	Start float64 `json:"start"`
	End   float64 `json:"end"`
	Text  string  `json:"text"`
}

type Whisper

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

func New

func New(models string) (*Whisper, error)

Create a new whisper instance with the specified path to the models directory

func (*Whisper) Close

func (w *Whisper) Close() error

Close the whisper instance and release resources

func (*Whisper) DeleteModelById

func (w *Whisper) DeleteModelById(id string) error

func (*Whisper) DownloadModel

func (w *Whisper) DownloadModel(ctx context.Context, name, dest string) (*Model, error)

func (*Whisper) GetModelById

func (w *Whisper) GetModelById(id string) *Model

func (*Whisper) ListModels

func (w *Whisper) ListModels() []*Model

func (*Whisper) Transcribe

func (w *Whisper) Transcribe(ctx *Context, samples []float32) (*Transcription, error)

Transcribe with a context

func (*Whisper) WithModelContext

func (w *Whisper) WithModelContext(model *Model, fn func(ctx *Context) error) error

Run with a context

Jump to

Keyboard shortcuts

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