Documentation
¶
Index ¶
- Constants
- Variables
- func FallbackDictationSegments(fullPCM []byte) []dictation.Segment
- type AudioRecorder
- type Command
- type CommandBus
- type CommandType
- type CommitObserver
- type Completion
- type DictationSegmenter
- type Engine
- type Event
- type EventType
- type Hooks
- type JobSubmitter
- type Persistence
- type QuickNoteStore
- type RecordingController
- type RecordingObserver
- type RecordingStartOptions
- type RecordingStopOptions
- type Runtime
- func (r *Runtime) Close()
- func (r *Runtime) Commands() CommandBus
- func (r *Runtime) Events() <-chan Event
- func (r *Runtime) Publish(event Event) bool
- func (r *Runtime) SetState(snapshot Snapshot)
- func (r *Runtime) Start(ctx context.Context) error
- func (r *Runtime) State() Snapshot
- func (r *Runtime) Stop(ctx context.Context) error
- func (r *Runtime) UpdateState(update func(*Snapshot)) Snapshot
- type SegmentCollector
- type SegmentCollectorFactory
- type Snapshot
- type Submission
- type Transcriber
- type Transcript
- type TranscriptInterceptor
- type TranscriptOutput
- type TranscriptionJob
- type TranscriptionObserver
- type TranscriptionRunner
- type TranscriptionStore
- type TranscriptionWorker
- type TranscriptionWorkerConfig
Constants ¶
View Source
const ( DefaultDictationMinSegment = 1200 * time.Millisecond DefaultDictationPadding = 160 * time.Millisecond DefaultDictationOverlap = 200 * time.Millisecond )
View Source
const DefaultMinPCMBytes = 3200
View Source
const DefaultProcessingMessage = "Recording stopped · Transcribing"
Variables ¶
View Source
var ( ErrMissingRunner = errors.New("speechkit: transcription worker requires a runner") ErrMissingTranscriber = errors.New("speechkit: transcription runner requires a transcriber") ErrWorkerClosed = errors.New("speechkit: transcription worker is closed") ErrWorkerQueueFull = errors.New("speechkit: transcription worker queue is full") )
Functions ¶
Types ¶
type AudioRecorder ¶
type Command ¶
type CommandType ¶
type CommandType string
const ( CommandShowDashboard CommandType = "dashboard.show" CommandStartDictation CommandType = "dictation.start" CommandStopDictation CommandType = "dictation.stop" CommandSetActiveMode CommandType = "mode.set_active" CommandOpenQuickNote CommandType = "quicknote.open" CommandOpenQuickCapture CommandType = "quicknote.capture.open" CommandCloseQuickCapture CommandType = "quicknote.capture.close" CommandArmQuickNoteRecording CommandType = "quicknote.record.arm" CommandCopyLastTranscription CommandType = "transcription.copy_last" CommandInsertLastTranscription CommandType = "transcription.insert_last" CommandSummarizeSelection CommandType = "selection.summarize" )
type CommitObserver ¶
type CommitObserver interface {
OnCommit(completion Completion)
}
type Completion ¶
type Completion struct {
Transcript Transcript
QuickNoteCommitted bool
QuickNoteCreated bool
QuickNoteID int64
TranscriptionPersisted bool
}
type DictationSegmenter ¶
type DictationSegmenter struct {
// contains filtered or unexported fields
}
func NewDictationSegmenter ¶
func NewDictationSegmenter(detector vad.Detector, pauseThreshold time.Duration) *DictationSegmenter
func (*DictationSegmenter) CollectStopSegments ¶
func (s *DictationSegmenter) CollectStopSegments(fullPCM []byte) ([]dictation.Segment, error)
func (*DictationSegmenter) FeedPCM ¶
func (s *DictationSegmenter) FeedPCM(pcm []byte) error
type EventType ¶
type EventType string
const ( EventStateChanged EventType = "state.changed" EventRecordingStarted EventType = "recording.started" EventProcessingStarted EventType = "processing.started" EventTranscriptionReady EventType = "transcription.ready" EventTranscriptCommitted EventType = "transcription.committed" EventQuickNoteModeArmed EventType = "quicknote.mode_armed" EventQuickNoteUpdated EventType = "quicknote.updated" EventWarningRaised EventType = "warning.raised" EventErrorRaised EventType = "error.raised" EventShortcutMatched EventType = "shortcut.matched" )
type JobSubmitter ¶
type JobSubmitter interface {
Submit(TranscriptionJob) error
}
type Persistence ¶
type Persistence interface {
QuickNoteStore
TranscriptionStore
}
type QuickNoteStore ¶
type QuickNoteStore interface {
SaveQuickNote(ctx context.Context, text, language, provider string, durationMs, latencyMs int64, audioData []byte) (int64, error)
GetQuickNoteText(ctx context.Context, id int64) (string, error)
UpdateQuickNote(ctx context.Context, id int64, text string) error
UpdateQuickNoteCapture(ctx context.Context, id int64, text, provider string, durationMs, latencyMs int64, audioData []byte) error
}
type RecordingController ¶
type RecordingController struct {
// contains filtered or unexported fields
}
func NewRecordingController ¶
func NewRecordingController(recorder AudioRecorder, submitter JobSubmitter, observer RecordingObserver, segmenterFactory SegmentCollectorFactory) *RecordingController
func (*RecordingController) IsRecording ¶
func (c *RecordingController) IsRecording() bool
func (*RecordingController) Start ¶
func (c *RecordingController) Start(opts RecordingStartOptions) error
func (*RecordingController) Stop ¶
func (c *RecordingController) Stop(opts RecordingStopOptions) error
type RecordingObserver ¶
type RecordingStartOptions ¶
type RecordingStopOptions ¶
type RecordingStopOptions struct {
Label string
}
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func NewRuntime ¶
func (*Runtime) Commands ¶
func (r *Runtime) Commands() CommandBus
func (*Runtime) UpdateState ¶
type SegmentCollector ¶
type SegmentCollectorFactory ¶
type SegmentCollectorFactory func() SegmentCollector
type Snapshot ¶
type Submission ¶
type Transcriber ¶
type Transcript ¶
type TranscriptInterceptor ¶
type TranscriptOutput ¶
type TranscriptOutput interface {
Deliver(ctx context.Context, transcript Transcript, target any) error
}
type TranscriptionJob ¶
type TranscriptionJob struct {
Submission
Target any
}
func (TranscriptionJob) Clone ¶
func (j TranscriptionJob) Clone() TranscriptionJob
type TranscriptionObserver ¶
type TranscriptionObserver interface {
OnState(status, text string)
OnLog(message, kind string)
OnTranscriptCommitted(transcript Transcript, quickNote bool)
}
type TranscriptionRunner ¶
type TranscriptionRunner struct {
// contains filtered or unexported fields
}
func NewTranscriptionRunner ¶
func NewTranscriptionRunner(transcriber Transcriber, store Persistence) *TranscriptionRunner
func (*TranscriptionRunner) Commit ¶
func (r *TranscriptionRunner) Commit(ctx context.Context, submission Submission, transcript Transcript) (Completion, error)
func (*TranscriptionRunner) WithObserver ¶
func (r *TranscriptionRunner) WithObserver(observer CommitObserver) *TranscriptionRunner
type TranscriptionStore ¶
type TranscriptionWorker ¶
type TranscriptionWorker struct {
// contains filtered or unexported fields
}
func NewTranscriptionWorker ¶
func NewTranscriptionWorker(cfg TranscriptionWorkerConfig) (*TranscriptionWorker, error)
func (*TranscriptionWorker) Close ¶
func (w *TranscriptionWorker) Close()
func (*TranscriptionWorker) Start ¶
func (w *TranscriptionWorker) Start(ctx context.Context)
func (*TranscriptionWorker) Submit ¶
func (w *TranscriptionWorker) Submit(job TranscriptionJob) error
func (*TranscriptionWorker) Wait ¶
func (w *TranscriptionWorker) Wait()
type TranscriptionWorkerConfig ¶
type TranscriptionWorkerConfig struct {
Timeout time.Duration
QueueSize int
Runner *TranscriptionRunner
Output TranscriptOutput
Interceptor TranscriptInterceptor
Observer TranscriptionObserver
}
Click to show internal directories.
Click to hide internal directories.