vad

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

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

func NewBase

func NewBase(label string, capabilities Capabilities) *Base

func (*Base) Capabilities

func (b *Base) Capabilities() Capabilities

func (*Base) EmitMetrics

func (b *Base) EmitMetrics(metric metrics.VAD)

func (*Base) Label

func (b *Base) Label() string

func (*Base) MinSilenceDuration

func (b *Base) MinSilenceDuration() (time.Duration, bool)

func (*Base) OnMetrics

func (b *Base) OnMetrics(fn func(metrics.VAD)) func()

func (*Base) SetMinSilenceDuration

func (b *Base) SetMinSilenceDuration(value time.Duration)

type BaseStream

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

func NewBaseStream

func NewBaseStream(parent context.Context, capacity int) *BaseStream

func (*BaseStream) Close

func (s *BaseStream) Close() error

func (*BaseStream) Context

func (s *BaseStream) Context() context.Context

func (*BaseStream) Emit

func (s *BaseStream) Emit(ctx context.Context, event Event) error

func (*BaseStream) EndInput

func (s *BaseStream) EndInput() error

func (*BaseStream) Finish

func (s *BaseStream) Finish(err error)

func (*BaseStream) Flush

func (s *BaseStream) Flush(ctx context.Context) error

func (*BaseStream) Inputs

func (s *BaseStream) Inputs() stream.Reader[StreamInput]

func (*BaseStream) Push

func (s *BaseStream) Push(ctx context.Context, frame agents.AudioFrame) error

func (*BaseStream) Recv

func (s *BaseStream) Recv(ctx context.Context) (Event, error)

type Capabilities

type Capabilities struct {
	UpdateInterval time.Duration
}

type Event

type Event struct {
	Type                  EventType
	SamplesIndex          int64
	Timestamp             time.Time
	SpeechDuration        time.Duration
	SilenceDuration       time.Duration
	Frames                []agents.AudioFrame
	Probability           float64
	InferenceDuration     time.Duration
	Speaking              bool
	RawAccumulatedSilence time.Duration
	RawAccumulatedSpeech  time.Duration
}

type EventType

type EventType uint8
const (
	StartOfSpeech EventType = iota
	InferenceDone
	EndOfSpeech
	MetricsCollected
)

type StreamInput

type StreamInput struct {
	Frame *agents.AudioFrame
	Flush bool
}

type VAD

type VAD interface {
	Label() string
	Capabilities() Capabilities
	MinSilenceDuration() (time.Duration, bool)
	Stream(context.Context) (VADStream, error)
	Close(context.Context) error
	OnMetrics(func(metrics.VAD)) func()
}

type VADStream

type VADStream interface {
	stream.Reader[Event]
	Push(context.Context, agents.AudioFrame) error
	Flush(context.Context) error
	EndInput() error
	Close() error
}

Jump to

Keyboard shortcuts

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