task

package
v0.0.12 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Context is used for running the transcription or translation

func New

func New() *Context

Create a new context object

func (*Context) CanTranslate

func (task *Context) CanTranslate() bool

Model is multilingual and can translate

func (*Context) Close

func (ctx *Context) Close() error

Close the context and release all resources. The context itself can be re-used by calling Init again

func (*Context) CopyParams

func (task *Context) CopyParams()

Reset task context for re-use

func (*Context) Init

func (m *Context) Init(path string, model *schema.Model, gpu int) error

Init the context

func (*Context) Is

func (ctx *Context) Is(model *schema.Model) bool

Context has a loaded model that matches the argument

func (*Context) MarshalJSON

func (ctx *Context) MarshalJSON() ([]byte, error)

func (*Context) Result

func (ctx *Context) Result() *schema.Transcription

Return the transcription result

func (*Context) SetLanguage

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

Set the language. For transcription, this is the language of the audio samples. For translation, this is the language to translate to. If you set this to "auto" then the language will be detected

func (*Context) SetTranslate

func (ctx *Context) SetTranslate(v bool)

Set translate to true or false

func (*Context) String

func (ctx *Context) String() string

func (*Context) Transcribe

func (task *Context) Transcribe(ctx context.Context, ts time.Duration, samples []float32, segments bool, fn NewSegmentFunc) error

Transcribe samples. The samples should be 16KHz float32 samples in a single channel. Appends the transcription to the result, and includes segment data if segments is true.

type NewSegmentFunc

type NewSegmentFunc func(*schema.Segment)

Callback for new segments during the transcription process

Jump to

Keyboard shortcuts

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