Define module interfaces

This commit is contained in:
Mariano Belinky 2026-01-04 18:28:39 +01:00
parent 2850843294
commit 2ca3f69fa8
4 changed files with 82 additions and 6 deletions

View File

@ -1,6 +1,35 @@
package audio
type Device struct {
Name string
ID string
import (
"context"
"time"
)
type Format struct {
SampleRate int
Channels int
Encoding string
}
type Frame struct {
Data []byte
Format Format
Timestamp time.Time
}
type Buffer struct {
Data []byte
Format Format
}
type Capture interface {
Name() string
Start(ctx context.Context) (<-chan Frame, error)
Close() error
}
type Playback interface {
Name() string
Play(ctx context.Context, in <-chan Frame) error
Close() error
}

View File

@ -1,6 +1,27 @@
package stt
import (
"context"
"time"
"github.com/clawdbot/clawgo/modules/audio"
)
type Transcript struct {
Text string
Source string
Text string
Final bool
Confidence float32
Timestamp time.Time
Source string
}
type Options struct {
Language string
Prompt string
Model string
}
type Engine interface {
Name() string
Transcribe(ctx context.Context, in <-chan audio.Frame, opts Options) (<-chan Transcript, error)
}

View File

@ -1,8 +1,20 @@
package tts
import (
"context"
"github.com/clawdbot/clawgo/modules/audio"
)
type Request struct {
Text string
Voice string
Rate int
Pitch float32
Engine string
}
type Engine interface {
Name() string
Synthesize(ctx context.Context, req Request) (audio.Buffer, error)
}

View File

@ -1,5 +1,19 @@
package wakeword
import (
"context"
"time"
"github.com/clawdbot/clawgo/modules/audio"
)
type Event struct {
Keyword string
Keyword string
Confidence float32
Timestamp time.Time
}
type Detector interface {
Name() string
Detect(ctx context.Context, in <-chan audio.Frame) (<-chan Event, error)
}