task

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteSegmentSrt

func WriteSegmentSrt(w io.Writer, seg *schema.Segment)

func WriteSegmentText

func WriteSegmentText(w io.Writer, seg *schema.Segment)

func WriteSegmentVtt

func WriteSegmentVtt(w io.Writer, seg *schema.Segment)

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) Diarize

func (ctx *Context) Diarize() bool

Return the diarize flag

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) Language

func (ctx *Context) Language() string

func (*Context) MarshalJSON

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

func (*Context) Result

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

Return the transcription result

func (*Context) SetDiarize

func (ctx *Context) SetDiarize(v bool)

Set diarize flag

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, 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 the new segment function is not nil

func (*Context) Translate

func (ctx *Context) Translate() bool

Return the translate flag

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