Define module interfaces
This commit is contained in:
parent
2850843294
commit
2ca3f69fa8
@ -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
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user