Documentation
¶
Index ¶
- Constants
- func ParseKeyterms(raw string) []string
- type FluxStreamOptions
- type FluxTurn
- type FluxTurnStream
- type FluxWord
- type Options
- type Provider
- func (p *Provider) ApplyOptions(opts Options)
- func (*Provider) Capabilities() []speechkit.Capability
- func (p *Provider) Health(ctx context.Context) error
- func (p *Provider) Name() string
- func (p *Provider) StartDictationStream(ctx context.Context, opts speechkit.DictationStreamOptions, ...) (speechkit.DictationStream, error)
- func (p *Provider) StartFluxTurnStream(ctx context.Context, opts FluxStreamOptions, format speaker.AudioFormat) (*FluxTurnStream, error)
- func (p *Provider) StartSpeakerStream(ctx context.Context, opts speaker.Options, format speaker.AudioFormat) (speaker.SpeakerStream, error)
- func (p *Provider) Transcribe(ctx context.Context, audio []byte, opts stt.TranscribeOpts) (*stt.Result, error)
Constants ¶
const ( FluxEventStartOfTurn = "StartOfTurn" FluxEventUpdate = "Update" FluxEventEagerEndOfTurn = "EagerEndOfTurn" FluxEventTurnResumed = "TurnResumed" FluxEventEndOfTurn = "EndOfTurn" )
Flux turn lifecycle events. A turn opens with StartOfTurn, grows through Update events, and closes with EndOfTurn. EagerEndOfTurn is a speculative signal — the model believes the speaker is done and a consumer may start generating a response — which TurnResumed retracts when the speaker continues.
const ( FluxEOTThresholdMin = 0.5 FluxEOTThresholdMax = 0.9 FluxEagerEOTThresholdMin = 0.3 FluxEagerEOTThresholdMax = 0.9 FluxEOTTimeoutMinMs = 500 FluxEOTTimeoutMaxMs = 60000 )
Flux tuning ranges, per the Deepgram Flux API reference.
const ( DeepgramFluxModelEN = "flux-general-en" DeepgramFluxModelMulti = "flux-general-multi" )
Deepgram Flux model identifiers.
const FluxAudioChunk = 80 * time.Millisecond
FluxAudioChunk is the chunk duration Deepgram recommends for Flux input.
Variables ¶
This section is empty.
Functions ¶
func ParseKeyterms ¶ added in v0.64.3
Types ¶
type FluxStreamOptions ¶
type FluxStreamOptions struct {
// Model selects flux-general-en or flux-general-multi. Empty uses the
// multilingual model, which is the point of Flux for SpeechKit: it detects
// and switches languages within a single conversation.
Model string
// LanguageHints biases recognition toward the given BCP-47 languages. Only
// flux-general-multi accepts hints; they narrow the model, they do not pin
// it, and every turn still reports what it actually heard.
LanguageHints []string
// Keyterms boost domain vocabulary (product names and other terms the model
// has not seen).
Keyterms []string
// EOTThreshold, EagerEOTThreshold, and EOTTimeoutMs tune turn detection.
// Zero keeps Deepgram's defaults; out-of-range values are clamped.
EOTThreshold float64
EagerEOTThreshold float64
EOTTimeoutMs int
}
FluxStreamOptions configures a Flux turn stream. The zero value is valid and selects the multilingual model with Deepgram's default turn detection.
type FluxTurn ¶
type FluxTurn struct {
// Event is one of the Flux lifecycle events above.
Event string `json:"event"`
// TurnIndex counts turns within the connection.
TurnIndex int `json:"turnIndex"`
// Transcript is the full turn transcript so far, not a delta.
Transcript string `json:"transcript"`
Words []FluxWord `json:"words,omitempty"`
// Languages are the languages actually detected in this turn; empty when
// the turn holds no speech yet.
Languages []string `json:"languages,omitempty"`
// EndOfTurnConfidence is the model's confidence that the speaker is done.
EndOfTurnConfidence float64 `json:"endOfTurnConfidence"`
// AudioWindowStartMs/EndMs bound the audio this turn covers.
AudioWindowStartMs int64 `json:"audioWindowStartMs"`
AudioWindowEndMs int64 `json:"audioWindowEndMs"`
// SequenceID is Deepgram's per-connection event counter.
SequenceID int64 `json:"sequenceId"`
// RequestID identifies the connection in Deepgram's logs.
RequestID string `json:"requestId"`
// LatencyMs is the time from stream open to this event.
LatencyMs int64 `json:"latencyMs"`
}
FluxTurn is one decoded TurnInfo event.
func (FluxTurn) IsFinal ¶ added in v0.64.3
IsFinal reports whether the turn is closed and the transcript will not grow.
func (FluxTurn) IsSpeculative ¶ added in v0.64.3
IsSpeculative reports whether the event is the eager end-of-turn signal, which TurnResumed can retract. A consumer may start work on it, but must be able to cancel that work.
type FluxTurnStream ¶
type FluxTurnStream struct {
// contains filtered or unexported fields
}
FluxTurnStream is a live Flux connection. Callers push PCM with SendPCM and read turn events with Receive until io.EOF.
func (*FluxTurnStream) Close ¶ added in v0.64.3
func (s *FluxTurnStream) Close() error
Close shuts the WebSocket down. It is safe to call more than once.
func (*FluxTurnStream) CloseStream ¶ added in v0.64.3
func (s *FluxTurnStream) CloseStream(ctx context.Context) error
CloseStream tells Deepgram no further audio is coming, so it can flush the open turn instead of waiting for the end-of-turn timeout.
func (*FluxTurnStream) Model ¶ added in v0.64.3
func (s *FluxTurnStream) Model() string
Model reports the Flux model this stream negotiated.
type FluxWord ¶
type FluxWord struct {
Text string `json:"text"`
Confidence float64 `json:"confidence"`
StartMs int64 `json:"startMs"`
EndMs int64 `json:"endMs"`
}
FluxWord is a single recognized word. Flux reports no speaker label and no separately punctuated form — the turn transcript carries the punctuation.
type Options ¶
type Options struct {
Configured bool
SmartFormat bool
Dictation bool
FillerWords bool
Numerals bool
DetectLanguage bool
LanguageOverride string
UseVocabularyKeyterms bool
Keyterms []string
EndpointingMs int
}
Options holds provider-specific Deepgram STT controls. These map to Deepgram Listen query parameters while keeping SpeechKit's public STT router interface provider-neutral.
type Provider ¶
type Provider struct {
APIKey string
Model string
DiarizationModel string
BaseURL string
Validation netsec.ValidationOptions
SmartFormat bool
Dictation bool
FillerWords bool
Numerals bool
DetectLanguage bool
LanguageOverride string
UseVocabularyKeyterms bool
// NoStore opts every request out of Deepgram's Model Improvement
// Partnership Program, so audio and transcript are kept only for as long
// as answering takes. Set by the host from its retention policy; the batch
// path also honours the per-request option.
NoStore bool
Keyterms []string
EndpointingMs int
// contains filtered or unexported fields
}
Provider transcribes through the Deepgram Listen API.
func (*Provider) ApplyOptions ¶ added in v0.64.3
func (*Provider) Capabilities ¶ added in v0.64.3
func (*Provider) Capabilities() []speechkit.Capability
Capabilities reports what this provider does beyond plain transcription.
func (*Provider) StartDictationStream ¶ added in v0.64.3
func (p *Provider) StartDictationStream(ctx context.Context, opts speechkit.DictationStreamOptions, format speaker.AudioFormat) (speechkit.DictationStream, error)
func (*Provider) StartFluxTurnStream ¶ added in v0.64.3
func (p *Provider) StartFluxTurnStream(ctx context.Context, opts FluxStreamOptions, format speaker.AudioFormat) (*FluxTurnStream, error)
StartFluxTurnStream opens a Deepgram Flux /v2/listen stream. The format must be raw PCM; Deepgram recommends 16 kHz mono and FluxAudioChunk-sized writes.
func (*Provider) StartSpeakerStream ¶ added in v0.64.3
func (p *Provider) StartSpeakerStream(ctx context.Context, opts speaker.Options, format speaker.AudioFormat) (speaker.SpeakerStream, error)