Documentation
¶
Index ¶
- Constants
- Variables
- func NormalizeLanguageTag(value string) (string, error)
- type Aligner
- type AlignmentConfig
- type AlignmentInfo
- type AudioChunk
- type AudioFormat
- type AudioPayload
- type AudioSession
- type AudioSessionContextUpdater
- type AudioSessionFactory
- type AudioSessionFactoryCatalog
- type AudioSessionMode
- type AudioSessionProvider
- type AudioSessionRequest
- type Capabilities
- type Client
- type ClientConfig
- type DashScopeInferenceRealtimeConfig
- type DashScopeInferenceRealtimeProvider
- func (p *DashScopeInferenceRealtimeProvider) Model() string
- func (p *DashScopeInferenceRealtimeProvider) Name() string
- func (p *DashScopeInferenceRealtimeProvider) ServerVADEnabled() bool
- func (p *DashScopeInferenceRealtimeProvider) Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
- func (p *DashScopeInferenceRealtimeProvider) StreamingCapabilities() StreamingCapabilities
- type ElevenLabsRealtimeConfig
- type ElevenLabsRealtimeProvider
- func (p *ElevenLabsRealtimeProvider) Model() string
- func (p *ElevenLabsRealtimeProvider) Name() string
- func (p *ElevenLabsRealtimeProvider) ServerVADEnabled() bool
- func (p *ElevenLabsRealtimeProvider) Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
- func (p *ElevenLabsRealtimeProvider) StreamingCapabilities() StreamingCapabilities
- type Event
- type EventError
- type EventType
- type EvidenceQuality
- type FinalAudioChunk
- type FinalizationReason
- type GeminiRealtimeConfig
- type GeminiRealtimeProvider
- func (p *GeminiRealtimeProvider) Model() string
- func (p *GeminiRealtimeProvider) Name() string
- func (p *GeminiRealtimeProvider) ServerVADEnabled() bool
- func (p *GeminiRealtimeProvider) Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
- func (p *GeminiRealtimeProvider) StreamingCapabilities() StreamingCapabilities
- type GenericHTTPConfig
- type GenericHTTPProvider
- type GraphemeTokenizer
- type InputRequirements
- type IntermediateResult
- type InworldRealtimeConfig
- type InworldRealtimeProvider
- func (p *InworldRealtimeProvider) Model() string
- func (p *InworldRealtimeProvider) Name() string
- func (p *InworldRealtimeProvider) ServerVADEnabled() bool
- func (p *InworldRealtimeProvider) Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
- func (p *InworldRealtimeProvider) StreamingCapabilities() StreamingCapabilities
- type MicrosoftHTTPConfig
- type MicrosoftHTTPProvider
- type OpenAIRealtimeConfig
- type OpenAIRealtimeProvider
- func (p *OpenAIRealtimeProvider) Model() string
- func (p *OpenAIRealtimeProvider) Name() string
- func (p *OpenAIRealtimeProvider) ServerVADEnabled() bool
- func (p *OpenAIRealtimeProvider) Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
- func (p *OpenAIRealtimeProvider) StreamingCapabilities() StreamingCapabilities
- func (p *OpenAIRealtimeProvider) TurnDetectionEnabled() bool
- type Provider
- type ProviderContextUpdater
- type ProviderRequest
- type ProviderResult
- type ProviderStream
- type ProviderStreamEvent
- type QwenOmniRealtimeConfig
- type QwenOmniRealtimeProvider
- func (p *QwenOmniRealtimeProvider) Model() string
- func (p *QwenOmniRealtimeProvider) Name() string
- func (p *QwenOmniRealtimeProvider) ServerVADEnabled() bool
- func (p *QwenOmniRealtimeProvider) Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
- func (p *QwenOmniRealtimeProvider) StreamingCapabilities() StreamingCapabilities
- type QwenRealtimeConfig
- type QwenRealtimeProvider
- func (p *QwenRealtimeProvider) Model() string
- func (p *QwenRealtimeProvider) Name() string
- func (p *QwenRealtimeProvider) ServerVADEnabled() bool
- func (p *QwenRealtimeProvider) Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
- func (p *QwenRealtimeProvider) StreamingCapabilities() StreamingCapabilities
- type RealtimeContextUpdateConfig
- type RealtimeSession
- func (s *RealtimeSession) Close()
- func (s *RealtimeSession) Done() <-chan struct{}
- func (s *RealtimeSession) Events() <-chan Event
- func (s *RealtimeSession) Finish(ctx context.Context, final FinalAudioChunk) error
- func (s *RealtimeSession) Mode() AudioSessionMode
- func (s *RealtimeSession) Push(ctx context.Context, chunk AudioChunk) error
- func (s *RealtimeSession) RecommendedWaitTimeout() time.Duration
- func (s *RealtimeSession) Requirements() InputRequirements
- func (s *RealtimeSession) UpdateContext(ctx context.Context, recognitionContext RecognitionContext) error
- func (s *RealtimeSession) Wait(ctx context.Context) error
- type RealtimeSessionConfig
- type RecognitionContext
- type Recognizer
- type RevisionBatch
- type ScheduledRecognizer
- func (r *ScheduledRecognizer) Close()
- func (r *ScheduledRecognizer) ProviderModel() string
- func (r *ScheduledRecognizer) ProviderName() string
- func (r *ScheduledRecognizer) Stats() SchedulerStats
- func (r *ScheduledRecognizer) Transcribe(ctx context.Context, request TranscriptionRequest) (TranscriptionResult, error)
- type SchedulerStats
- type Segment
- type SegmentRecognitionStrategy
- type SegmentRef
- type SegmentResult
- type SegmentedSession
- func (s *SegmentedSession) Close()
- func (s *SegmentedSession) Done() <-chan struct{}
- func (s *SegmentedSession) Events() <-chan Event
- func (s *SegmentedSession) Finish(ctx context.Context, final FinalAudioChunk) error
- func (s *SegmentedSession) Mode() AudioSessionMode
- func (s *SegmentedSession) Push(ctx context.Context, chunk AudioChunk) error
- func (s *SegmentedSession) RecommendedWaitTimeout() time.Duration
- func (s *SegmentedSession) Requirements() InputRequirements
- func (s *SegmentedSession) Wait(ctx context.Context) error
- type SegmentedSessionConfig
- type Session
- func (s *Session) AddSegment(ctx context.Context, segment Segment) error
- func (s *Session) Close()
- func (s *Session) Done() <-chan struct{}
- func (s *Session) Events() <-chan Event
- func (s *Session) SpeechEnded(ctx context.Context, streamDuration float64) error
- func (s *Session) SpeechSplit(ctx context.Context) error
- func (s *Session) SpeechStarted(ctx context.Context) error
- func (s *Session) Stop(ctx context.Context) error
- func (s *Session) Wait(ctx context.Context) error
- type SessionConfig
- type SpeechBoundary
- type SpeechBoundaryType
- type StreamingAudioChunk
- type StreamingCapabilities
- type StreamingContextUpdate
- type StreamingProvider
- type StreamingRequest
- type TextAlignment
- type TextToken
- type Tokenizer
- type TranscriptState
- type TranscriptionRequest
- type TranscriptionResult
- type VLLMRealtimeConfig
- type VLLMRealtimeProvider
- func (p *VLLMRealtimeProvider) Model() string
- func (p *VLLMRealtimeProvider) Name() string
- func (p *VLLMRealtimeProvider) ServerVADEnabled() bool
- func (p *VLLMRealtimeProvider) Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
- func (p *VLLMRealtimeProvider) StreamingCapabilities() StreamingCapabilities
- type WindowResult
- type Word
Constants ¶
const ( ElevenLabsCommitStrategyManual = "manual" ElevenLabsCommitStrategyVAD = "vad" )
const ( GeminiStartSensitivityHigh = "START_SENSITIVITY_HIGH" GeminiStartSensitivityLow = "START_SENSITIVITY_LOW" GeminiEndSensitivityHigh = "END_SENSITIVITY_HIGH" GeminiEndSensitivityLow = "END_SENSITIVITY_LOW" )
const ( OpenAIRealtimeDelayMinimal = "minimal" OpenAIRealtimeDelayLow = "low" OpenAIRealtimeDelayMedium = "medium" OpenAIRealtimeDelayHigh = "high" OpenAIRealtimeDelayXHigh = "xhigh" OpenAITurnDetectionServerVAD = "server_vad" OpenAITurnDetectionSemanticVAD = "semantic_vad" OpenAISemanticVADEagernessLow = "low" OpenAISemanticVADEagernessMedium = "medium" OpenAISemanticVADEagernessHigh = "high" OpenAISemanticVADEagernessAuto = "auto" )
const ( QwenOmniTurnDetectionServer = "server_vad" QwenOmniTurnDetectionSemantic = "semantic_vad" )
Variables ¶
var ( ErrInvalidConfig = errors.New("asr config invalid") ErrInvalidRequest = errors.New("asr request invalid") ErrProviderRequest = errors.New("asr provider request failed") ErrProviderResponse = errors.New("asr provider response invalid") ErrNoSpeech = errors.New("asr no speech detected") ErrRequestTimeout = errors.New("asr request timeout") ErrRequestSuperseded = errors.New("asr request superseded by newer audio") ErrRateLimited = errors.New("asr provider rate limited") ErrOverloaded = errors.New("asr service overloaded") ErrSessionClosed = errors.New("asr session closed") ErrSegmentInvalid = errors.New("asr segment invalid") ErrWindowTooLong = errors.New("asr window duration exceeded") ErrAlignmentRejected = errors.New("asr text alignment rejected") ErrLanguageInvalid = errors.New("asr language tag invalid") ErrPCMBufferLimit = errors.New("asr pcm buffer limit exceeded") ErrStreamingBackpressure = errors.New("asr streaming backpressure") ErrContextUpdateUnsupported = errors.New("asr context update unsupported") )
Functions ¶
func NormalizeLanguageTag ¶
NormalizeLanguageTag canonicalizes a BCP 47 tag. The ASR-specific "auto" sentinel is preserved for providers that support automatic detection.
Types ¶
type Aligner ¶
type Aligner struct {
// contains filtered or unexported fields
}
func NewAligner ¶
func NewAligner(tokenizer Tokenizer, cfg AlignmentConfig) *Aligner
func (*Aligner) AlignSuffixPrefix ¶
func (a *Aligner) AlignSuffixPrefix(previous, current string, protectedTerms []string) (TextAlignment, error)
type AlignmentConfig ¶
type AlignmentInfo ¶
type AudioChunk ¶
type AudioChunk struct {
Samples []float32
Boundaries []SpeechBoundary
}
type AudioFormat ¶
type AudioFormat string
const ( AudioFormatWAVPCM16 AudioFormat = "wav_pcm_s16le" AudioFormatRawPCM16 AudioFormat = "raw_pcm_s16le" )
type AudioPayload ¶
type AudioPayload struct {
Data []byte
Format AudioFormat
SampleRate int
Channels int
}
func EncodeAudio ¶
func EncodeAudio(samples []float32, sampleRate, channels int, format AudioFormat) (AudioPayload, error)
type AudioSession ¶
type AudioSession interface {
Mode() AudioSessionMode
Requirements() InputRequirements
Push(ctx context.Context, chunk AudioChunk) error
Finish(ctx context.Context, final FinalAudioChunk) error
Events() <-chan Event
Done() <-chan struct{}
Wait(ctx context.Context) error
RecommendedWaitTimeout() time.Duration
Close()
}
AudioSession is transport-neutral. PCM may come from a WebSocket, a file, a microphone, or any other source.
type AudioSessionContextUpdater ¶ added in v1.0.1
type AudioSessionContextUpdater interface {
UpdateContext(ctx context.Context, context RecognitionContext) error
}
AudioSessionContextUpdater is an optional extension for sessions whose provider can replace recognition context while audio streaming continues.
type AudioSessionFactory ¶
type AudioSessionFactory interface {
Mode() AudioSessionMode
NewAudioSession(ctx context.Context, request AudioSessionRequest) (AudioSession, error)
}
AudioSessionFactory lets applications select a segmented HTTP or realtime streaming backend without coupling their input transport to either one.
type AudioSessionFactoryCatalog ¶
type AudioSessionFactoryCatalog interface {
DefaultProvider() string
Providers() []AudioSessionProvider
Resolve(provider string, strategy SegmentRecognitionStrategy) (AudioSessionFactory, error)
}
AudioSessionFactoryCatalog resolves a provider and segmented recognition strategy for one input session. Applications can expose Providers safely to clients because the descriptors contain names and modes only.
type AudioSessionMode ¶
type AudioSessionMode string
const ( AudioSessionModeSegmentedHTTP AudioSessionMode = "segmented_http" AudioSessionModeRealtimeWebSocket AudioSessionMode = "realtime_websocket" )
type AudioSessionProvider ¶
type AudioSessionProvider struct {
Name string `json:"name"`
Mode AudioSessionMode `json:"mode"`
}
AudioSessionProvider describes a server-configured factory that callers may select by name. It intentionally contains no endpoint or credential data.
type AudioSessionRequest ¶
type AudioSessionRequest struct {
SessionID string
Language string
LanguageHints []string
Context RecognitionContext
SampleRate int
Channels int
MaxBufferedSamples int
}
AudioSessionRequest contains only source/session metadata. Provider and scheduling policy remain owned by the factory implementation.
type Capabilities ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ProviderModel ¶
func (*Client) ProviderName ¶
func (*Client) Transcribe ¶
func (c *Client) Transcribe(ctx context.Context, request TranscriptionRequest) (TranscriptionResult, error)
type ClientConfig ¶
type ClientConfig struct {
RequestTimeout time.Duration
RetryCount int
MaxConcurrency int
AudioFormat AudioFormat
}
type DashScopeInferenceRealtimeConfig ¶ added in v1.0.1
type DashScopeInferenceRealtimeConfig struct {
Name string
Model string
Endpoint string
APIKey string
WorkspaceID string
UserAgent string
VocabularyID string
VocabularyWeight int
SemanticPunctuationEnabled bool
MaxSentenceSilence time.Duration
MultiThresholdModeEnabled bool
Heartbeat bool
SpeechNoiseThreshold *float64
SpecialWordFilter string
HandshakeTimeout time.Duration
WriteTimeout time.Duration
FinishTimeout time.Duration
EventBuffer int
AllowInsecureWebSocket bool
}
type DashScopeInferenceRealtimeProvider ¶ added in v1.0.1
type DashScopeInferenceRealtimeProvider struct {
// contains filtered or unexported fields
}
func NewDashScopeInferenceRealtimeProvider ¶ added in v1.0.1
func NewDashScopeInferenceRealtimeProvider( cfg DashScopeInferenceRealtimeConfig, ) (*DashScopeInferenceRealtimeProvider, error)
func (*DashScopeInferenceRealtimeProvider) Model ¶ added in v1.0.1
func (p *DashScopeInferenceRealtimeProvider) Model() string
func (*DashScopeInferenceRealtimeProvider) Name ¶ added in v1.0.1
func (p *DashScopeInferenceRealtimeProvider) Name() string
func (*DashScopeInferenceRealtimeProvider) ServerVADEnabled ¶ added in v1.0.1
func (p *DashScopeInferenceRealtimeProvider) ServerVADEnabled() bool
func (*DashScopeInferenceRealtimeProvider) Start ¶ added in v1.0.1
func (p *DashScopeInferenceRealtimeProvider) Start( ctx context.Context, request StreamingRequest, ) (ProviderStream, error)
func (*DashScopeInferenceRealtimeProvider) StreamingCapabilities ¶ added in v1.0.1
func (p *DashScopeInferenceRealtimeProvider) StreamingCapabilities() StreamingCapabilities
type ElevenLabsRealtimeConfig ¶
type ElevenLabsRealtimeConfig struct {
Name string
Endpoint string
Model string
APIKey string
CommitStrategy string
VADSilenceThreshold time.Duration
VADThreshold *float64
MinSpeechDuration time.Duration
MinSilenceDuration time.Duration
ManualCommitInterval time.Duration
DisableTimestamps bool
DisableLanguageDetection bool
NoVerbatim bool
FilterBackgroundAudio bool
DisableLogging bool
EmitPartials bool
MinTranscriptLogProb *float64
HandshakeTimeout time.Duration
WriteTimeout time.Duration
FinishTimeout time.Duration
EventBuffer int
AllowInsecureWebSocket bool
}
type ElevenLabsRealtimeProvider ¶
type ElevenLabsRealtimeProvider struct {
// contains filtered or unexported fields
}
func NewElevenLabsRealtimeProvider ¶
func NewElevenLabsRealtimeProvider(cfg ElevenLabsRealtimeConfig) (*ElevenLabsRealtimeProvider, error)
func (*ElevenLabsRealtimeProvider) Model ¶
func (p *ElevenLabsRealtimeProvider) Model() string
func (*ElevenLabsRealtimeProvider) Name ¶
func (p *ElevenLabsRealtimeProvider) Name() string
func (*ElevenLabsRealtimeProvider) ServerVADEnabled ¶
func (p *ElevenLabsRealtimeProvider) ServerVADEnabled() bool
func (*ElevenLabsRealtimeProvider) Start ¶
func (p *ElevenLabsRealtimeProvider) Start( ctx context.Context, request StreamingRequest, ) (ProviderStream, error)
func (*ElevenLabsRealtimeProvider) StreamingCapabilities ¶
func (p *ElevenLabsRealtimeProvider) StreamingCapabilities() StreamingCapabilities
type Event ¶
type Event struct {
Type EventType `json:"type"`
SessionID string `json:"session_id"`
Sequence uint64 `json:"sequence"`
Timestamp time.Time `json:"timestamp"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Intermediate *IntermediateResult `json:"intermediate,omitempty"`
Segment *SegmentResult `json:"segment,omitempty"`
Window *WindowResult `json:"window,omitempty"`
RevisionBatch *RevisionBatch `json:"revision_batch,omitempty"`
Error *EventError `json:"error,omitempty"`
}
type EventError ¶
type EventType ¶
type EventType string
const ( EventSessionReady EventType = "asr.session_ready" EventIntermediateResult EventType = "asr.intermediate_result" EventSegmentResult EventType = "asr.segment_result" EventWindowResult EventType = "asr.window_result" EventRevisionBatch EventType = "asr.revision_batch" EventRecognitionError EventType = "asr.error" EventCompleted EventType = "asr.session_completed" )
type EvidenceQuality ¶
type EvidenceQuality string
const ( EvidenceCrossWindowHigh EvidenceQuality = "cross_window_high" EvidenceProviderTime EvidenceQuality = "provider_timestamp" EvidenceStandalone EvidenceQuality = "standalone" EvidenceDegraded EvidenceQuality = "degraded" EvidenceProviderFinal EvidenceQuality = "provider_final" )
type FinalAudioChunk ¶
type FinalAudioChunk struct {
Samples []float32
Boundaries []SpeechBoundary
FinalBoundaries []SpeechBoundary
}
FinalAudioChunk contains only finish-time PCM and boundary deltas. Callers must not pass their complete VAD history in FinalBoundaries.
type FinalizationReason ¶
type FinalizationReason string
const ( FinalizationNextWindow FinalizationReason = "next_window" FinalizationSilenceTimeout FinalizationReason = "silence_timeout" FinalizationLongSegment FinalizationReason = "long_segment_boundary" FinalizationLongSpeech FinalizationReason = "long_speech_commit" FinalizationAudioStop FinalizationReason = "audio_stop" FinalizationRequestTimeout FinalizationReason = "request_timeout_degraded" FinalizationProviderFinal FinalizationReason = "provider_final" )
type GeminiRealtimeConfig ¶
type GeminiRealtimeConfig struct {
Name string
Endpoint string
Model string
APIKey string
SystemInstruction string
StartOfSpeechSensitivity string
EndOfSpeechSensitivity string
PrefixPadding time.Duration
SilenceDuration time.Duration
MaxContinuousTurn time.Duration
FinalTranscriptDrain time.Duration
FinishIdleTimeout time.Duration
HandshakeTimeout time.Duration
WriteTimeout time.Duration
FinishTimeout time.Duration
EventBuffer int
DisableContextWindowCompression bool
DisableContinuousTurnFlush bool
AllowInsecureWebSocket bool
}
type GeminiRealtimeProvider ¶
type GeminiRealtimeProvider struct {
// contains filtered or unexported fields
}
GeminiRealtimeProvider implements the Gemini Live API raw WebSocket protocol for input audio transcription.
func NewGeminiRealtimeProvider ¶
func NewGeminiRealtimeProvider(cfg GeminiRealtimeConfig) (*GeminiRealtimeProvider, error)
func (*GeminiRealtimeProvider) Model ¶
func (p *GeminiRealtimeProvider) Model() string
func (*GeminiRealtimeProvider) Name ¶
func (p *GeminiRealtimeProvider) Name() string
func (*GeminiRealtimeProvider) ServerVADEnabled ¶
func (p *GeminiRealtimeProvider) ServerVADEnabled() bool
func (*GeminiRealtimeProvider) Start ¶
func (p *GeminiRealtimeProvider) Start( ctx context.Context, request StreamingRequest, ) (ProviderStream, error)
func (*GeminiRealtimeProvider) StreamingCapabilities ¶
func (p *GeminiRealtimeProvider) StreamingCapabilities() StreamingCapabilities
type GenericHTTPConfig ¶
type GenericHTTPConfig struct {
Name string
Model string
BaseURL string
Path string
APIKey string
AuthHeader string
AuthScheme string
FileField string
ModelField string
LanguageField string
PromptField string
TermsField string
LanguageHintsField string
ExtraFields map[string]string
RequireAPIKey bool
OmitModel bool
OmitLanguage bool
OmitPrompt bool
OmitTerms bool
OmitLanguageHints bool
ResponseBodyLimit int
AllowInsecureHTTP bool
SupportsWordTimes bool
SupportsAutoLanguage bool
SupportsLanguageHints bool
StripLeadingLanguageLabel bool
AudioFormat AudioFormat
}
type GenericHTTPProvider ¶
type GenericHTTPProvider struct {
// contains filtered or unexported fields
}
func NewGenericHTTPProvider ¶
func NewGenericHTTPProvider(cfg GenericHTTPConfig) (*GenericHTTPProvider, error)
func (*GenericHTTPProvider) Capabilities ¶
func (p *GenericHTTPProvider) Capabilities() Capabilities
func (*GenericHTTPProvider) Model ¶
func (p *GenericHTTPProvider) Model() string
func (*GenericHTTPProvider) Name ¶
func (p *GenericHTTPProvider) Name() string
func (*GenericHTTPProvider) Transcribe ¶
func (p *GenericHTTPProvider) Transcribe(ctx context.Context, request ProviderRequest) (ProviderResult, error)
type GraphemeTokenizer ¶
type GraphemeTokenizer struct{}
type InputRequirements ¶
type IntermediateResult ¶
type IntermediateResult struct {
Text string `json:"text"`
Provider string `json:"provider"`
Model string `json:"model"`
SegmentIndex int `json:"segment_index"`
StartAt float64 `json:"start_at"`
EndAt float64 `json:"end_at"`
}
IntermediateResult is a non-authoritative transcript from the beginning of the current physical speech region to a confirmed soft boundary.
type InworldRealtimeConfig ¶
type InworldRealtimeConfig struct {
Name string
Endpoint string
Model string
APIKey string
InactivityTimeout time.Duration
EndOfTurnConfidenceThreshold *float64
VADThreshold *float64
MinEndOfTurnSilence time.Duration
DisableServerVAD bool
IncludeWordTimestamps bool
DisablePartials bool
HandshakeTimeout time.Duration
WriteTimeout time.Duration
FinishTimeout time.Duration
EventBuffer int
AllowInsecureWebSocket bool
}
type InworldRealtimeProvider ¶
type InworldRealtimeProvider struct {
// contains filtered or unexported fields
}
func NewInworldRealtimeProvider ¶
func NewInworldRealtimeProvider(cfg InworldRealtimeConfig) (*InworldRealtimeProvider, error)
func (*InworldRealtimeProvider) Model ¶
func (p *InworldRealtimeProvider) Model() string
func (*InworldRealtimeProvider) Name ¶
func (p *InworldRealtimeProvider) Name() string
func (*InworldRealtimeProvider) ServerVADEnabled ¶
func (p *InworldRealtimeProvider) ServerVADEnabled() bool
func (*InworldRealtimeProvider) Start ¶
func (p *InworldRealtimeProvider) Start( ctx context.Context, request StreamingRequest, ) (ProviderStream, error)
func (*InworldRealtimeProvider) StreamingCapabilities ¶
func (p *InworldRealtimeProvider) StreamingCapabilities() StreamingCapabilities
type MicrosoftHTTPConfig ¶
type MicrosoftHTTPConfig struct {
Name string
Model string
Endpoint string
APIKey string
AuthMode string
DefaultLanguage string
ResponseBodyLimit int
AllowInsecureHTTP bool
}
MicrosoftHTTPConfig configures the Microsoft Speech REST conversation API. Endpoint may be either a regional root URL or the complete recognition URL.
type MicrosoftHTTPProvider ¶
type MicrosoftHTTPProvider struct {
// contains filtered or unexported fields
}
MicrosoftHTTPProvider sends complete VAD/window WAV payloads to Microsoft Speech. It deliberately implements Provider rather than StreamingProvider: Microsoft server events and audio streaming are a separate protocol.
func NewMicrosoftHTTPProvider ¶
func NewMicrosoftHTTPProvider(cfg MicrosoftHTTPConfig) (*MicrosoftHTTPProvider, error)
func (*MicrosoftHTTPProvider) Capabilities ¶
func (p *MicrosoftHTTPProvider) Capabilities() Capabilities
func (*MicrosoftHTTPProvider) Model ¶
func (p *MicrosoftHTTPProvider) Model() string
func (*MicrosoftHTTPProvider) Name ¶
func (p *MicrosoftHTTPProvider) Name() string
func (*MicrosoftHTTPProvider) Transcribe ¶
func (p *MicrosoftHTTPProvider) Transcribe( ctx context.Context, request ProviderRequest, ) (ProviderResult, error)
type OpenAIRealtimeConfig ¶
type OpenAIRealtimeConfig struct {
Name string
Endpoint string
Model string
APIKey string
Delay string
TurnDetectionType string
SemanticVADEagerness string
ServerVADThreshold *float64
ServerVADPrefixPadding time.Duration
ServerVADSilence time.Duration
DisableTurnDetection bool
CommitInterval time.Duration
HandshakeTimeout time.Duration
WriteTimeout time.Duration
FinishTimeout time.Duration
EventBuffer int
AllowInsecureWebSocket bool
}
type OpenAIRealtimeProvider ¶
type OpenAIRealtimeProvider struct {
// contains filtered or unexported fields
}
OpenAIRealtimeProvider implements OpenAI's GA realtime transcription WebSocket protocol.
func NewOpenAIRealtimeProvider ¶
func NewOpenAIRealtimeProvider(cfg OpenAIRealtimeConfig) (*OpenAIRealtimeProvider, error)
func (*OpenAIRealtimeProvider) Model ¶
func (p *OpenAIRealtimeProvider) Model() string
func (*OpenAIRealtimeProvider) Name ¶
func (p *OpenAIRealtimeProvider) Name() string
func (*OpenAIRealtimeProvider) ServerVADEnabled ¶
func (p *OpenAIRealtimeProvider) ServerVADEnabled() bool
ServerVADEnabled retains the common streaming-provider contract. For this provider, true means either server_vad or semantic_vad is enabled.
func (*OpenAIRealtimeProvider) Start ¶
func (p *OpenAIRealtimeProvider) Start( ctx context.Context, request StreamingRequest, ) (ProviderStream, error)
func (*OpenAIRealtimeProvider) StreamingCapabilities ¶
func (p *OpenAIRealtimeProvider) StreamingCapabilities() StreamingCapabilities
func (*OpenAIRealtimeProvider) TurnDetectionEnabled ¶
func (p *OpenAIRealtimeProvider) TurnDetectionEnabled() bool
TurnDetectionEnabled reports whether OpenAI owns utterance boundaries.
type Provider ¶
type Provider interface {
Name() string
Model() string
Capabilities() Capabilities
Transcribe(ctx context.Context, request ProviderRequest) (ProviderResult, error)
}
type ProviderContextUpdater ¶ added in v1.0.1
type ProviderContextUpdater interface {
UpdateContext(ctx context.Context, update StreamingContextUpdate) error
}
ProviderContextUpdater is an optional extension implemented by streams that can update recognition context without reconnecting or dropping audio.
type ProviderRequest ¶
type ProviderRequest struct {
RequestID string
SessionID string
Language string
LanguageHints []string
Context RecognitionContext
Audio AudioPayload
}
type ProviderResult ¶
type ProviderStream ¶
type ProviderStream interface {
WriteAudio(ctx context.Context, chunk StreamingAudioChunk) error
CloseInput(ctx context.Context) error
Events() <-chan ProviderStreamEvent
Done() <-chan struct{}
Wait(ctx context.Context) error
Close()
}
ProviderStream adapters own their provider connection, writer, reader, handshake, keepalive, and provider-specific message protocol.
type ProviderStreamEvent ¶
type QwenOmniRealtimeConfig ¶
type QwenOmniRealtimeConfig struct {
Name string
Model string
Endpoint string
APIKey string
WorkspaceID string
TurnDetectionType string
Instructions string
VADThreshold *float64
VADSilenceDuration time.Duration
HandshakeTimeout time.Duration
WriteTimeout time.Duration
FinishTimeout time.Duration
EventBuffer int
DisableServerVAD bool
KeepModelResponses bool
AllowInsecureWebSocket bool
}
type QwenOmniRealtimeProvider ¶
type QwenOmniRealtimeProvider struct {
// contains filtered or unexported fields
}
QwenOmniRealtimeProvider uses Qwen-Omni-Realtime's input transcription events as an ASR stream. The Omni model's assistant responses are canceled by default because they are outside this provider's ASR-only contract.
func NewQwenOmniRealtimeProvider ¶
func NewQwenOmniRealtimeProvider(cfg QwenOmniRealtimeConfig) (*QwenOmniRealtimeProvider, error)
func (*QwenOmniRealtimeProvider) Model ¶
func (p *QwenOmniRealtimeProvider) Model() string
func (*QwenOmniRealtimeProvider) Name ¶
func (p *QwenOmniRealtimeProvider) Name() string
func (*QwenOmniRealtimeProvider) ServerVADEnabled ¶
func (p *QwenOmniRealtimeProvider) ServerVADEnabled() bool
func (*QwenOmniRealtimeProvider) Start ¶
func (p *QwenOmniRealtimeProvider) Start( ctx context.Context, request StreamingRequest, ) (ProviderStream, error)
func (*QwenOmniRealtimeProvider) StreamingCapabilities ¶
func (p *QwenOmniRealtimeProvider) StreamingCapabilities() StreamingCapabilities
type QwenRealtimeConfig ¶
type QwenRealtimeConfig struct {
Name string
Model string
Endpoint string
APIKey string
WorkspaceID string
ServerVADThreshold float64
ServerVADSilenceDuration time.Duration
DisableServerVAD bool
HandshakeTimeout time.Duration
WriteTimeout time.Duration
FinishTimeout time.Duration
EventBuffer int
AllowInsecureWebSocket bool
}
type QwenRealtimeProvider ¶
type QwenRealtimeProvider struct {
// contains filtered or unexported fields
}
func NewQwenRealtimeProvider ¶
func NewQwenRealtimeProvider(cfg QwenRealtimeConfig) (*QwenRealtimeProvider, error)
func (*QwenRealtimeProvider) Model ¶
func (p *QwenRealtimeProvider) Model() string
func (*QwenRealtimeProvider) Name ¶
func (p *QwenRealtimeProvider) Name() string
func (*QwenRealtimeProvider) ServerVADEnabled ¶
func (p *QwenRealtimeProvider) ServerVADEnabled() bool
ServerVADEnabled reports the normalized Qwen provider policy. Server VAD is enabled by default and can only be disabled explicitly in provider config.
func (*QwenRealtimeProvider) Start ¶
func (p *QwenRealtimeProvider) Start( ctx context.Context, request StreamingRequest, ) (ProviderStream, error)
func (*QwenRealtimeProvider) StreamingCapabilities ¶
func (p *QwenRealtimeProvider) StreamingCapabilities() StreamingCapabilities
type RealtimeContextUpdateConfig ¶ added in v1.0.1
type RealtimeSession ¶
type RealtimeSession struct {
// contains filtered or unexported fields
}
RealtimeSession adapts a persistent provider stream to AudioSession. It accepts denoised float32 PCM and deliberately ignores local VAD boundaries; utterance detection, when enabled, belongs to the remote provider.
func NewRealtimeSession ¶
func NewRealtimeSession( ctx context.Context, provider StreamingProvider, cfg RealtimeSessionConfig, ) (*RealtimeSession, error)
func (*RealtimeSession) Close ¶
func (s *RealtimeSession) Close()
func (*RealtimeSession) Done ¶
func (s *RealtimeSession) Done() <-chan struct{}
func (*RealtimeSession) Events ¶
func (s *RealtimeSession) Events() <-chan Event
func (*RealtimeSession) Finish ¶
func (s *RealtimeSession) Finish(ctx context.Context, final FinalAudioChunk) error
func (*RealtimeSession) Mode ¶
func (s *RealtimeSession) Mode() AudioSessionMode
func (*RealtimeSession) Push ¶
func (s *RealtimeSession) Push(ctx context.Context, chunk AudioChunk) error
func (*RealtimeSession) RecommendedWaitTimeout ¶
func (s *RealtimeSession) RecommendedWaitTimeout() time.Duration
func (*RealtimeSession) Requirements ¶
func (s *RealtimeSession) Requirements() InputRequirements
func (*RealtimeSession) UpdateContext ¶ added in v1.0.1
func (s *RealtimeSession) UpdateContext(ctx context.Context, recognitionContext RecognitionContext) error
type RealtimeSessionConfig ¶
type RealtimeSessionConfig struct {
Request StreamingRequest
EventBuffer int
MinimumWaitTimeout time.Duration
ChunkDuration time.Duration
ContextUpdate RealtimeContextUpdateConfig
}
type RecognitionContext ¶
type Recognizer ¶
type Recognizer interface {
ProviderName() string
ProviderModel() string
Transcribe(ctx context.Context, request TranscriptionRequest) (TranscriptionResult, error)
}
type RevisionBatch ¶
type RevisionBatch struct {
ID string `json:"revision_batch_id"`
EvidenceRequestIDs []string `json:"evidence_request_ids"`
EvidenceWindowIndices []int `json:"evidence_window_indices"`
Segments []SegmentResult `json:"segments"`
Alignment AlignmentInfo `json:"alignment"`
}
type ScheduledRecognizer ¶
type ScheduledRecognizer struct {
// contains filtered or unexported fields
}
ScheduledRecognizer serializes requests while preserving authoritative work and coalescing pending preview work to the newest audio boundary.
func NewScheduledRecognizer ¶
func NewScheduledRecognizer(ctx context.Context, base Recognizer) (*ScheduledRecognizer, error)
NewScheduledRecognizer wraps base with a session-scoped request scheduler. Canceling ctx or calling Close stops the scheduler and its active request.
func (*ScheduledRecognizer) Close ¶
func (r *ScheduledRecognizer) Close()
Close stops the scheduler and waits for its scheduling loop to exit.
func (*ScheduledRecognizer) ProviderModel ¶
func (r *ScheduledRecognizer) ProviderModel() string
ProviderModel returns the wrapped recognizer's model name.
func (*ScheduledRecognizer) ProviderName ¶
func (r *ScheduledRecognizer) ProviderName() string
ProviderName returns the wrapped recognizer's provider name.
func (*ScheduledRecognizer) Stats ¶
func (r *ScheduledRecognizer) Stats() SchedulerStats
Stats returns the current scheduler counters and pending state.
func (*ScheduledRecognizer) Transcribe ¶
func (r *ScheduledRecognizer) Transcribe( ctx context.Context, request TranscriptionRequest, ) (TranscriptionResult, error)
Transcribe schedules one request and waits for its result.
type SchedulerStats ¶
type SchedulerStats struct {
Superseded uint64
AuthoritativePending int64
AuthoritativeOutstanding int64
PreviewPending bool
}
SchedulerStats is a lock-free snapshot of one ScheduledRecognizer.
type SegmentRecognitionStrategy ¶
type SegmentRecognitionStrategy string
const ( SegmentRecognitionStrategyContextual SegmentRecognitionStrategy = "contextual" SegmentRecognitionStrategySingle SegmentRecognitionStrategy = "single_segment" )
type SegmentRef ¶
type SegmentResult ¶
type SegmentResult struct {
SegmentIndex int `json:"segment_index"`
SourceWindowIndex int `json:"source_window_index"`
Revision int `json:"revision"`
State TranscriptState `json:"stability"`
Text string `json:"text"`
FinalizationReason FinalizationReason `json:"finalization_reason,omitempty"`
EvidenceQuality EvidenceQuality `json:"evidence_quality,omitempty"`
}
type SegmentedSession ¶
type SegmentedSession struct {
// contains filtered or unexported fields
}
SegmentedSession turns a continuous PCM stream plus transport-neutral speech boundaries into either contextual rolling windows or direct single-segment requests, according to Session.SegmentStrategy. Push and Finish are serialized because audio chunks are an ordered stream.
func NewSegmentedSession ¶
func NewSegmentedSession( ctx context.Context, recognizer Recognizer, cfg SegmentedSessionConfig, ) (*SegmentedSession, error)
func (*SegmentedSession) Close ¶
func (s *SegmentedSession) Close()
func (*SegmentedSession) Done ¶
func (s *SegmentedSession) Done() <-chan struct{}
func (*SegmentedSession) Events ¶
func (s *SegmentedSession) Events() <-chan Event
func (*SegmentedSession) Finish ¶
func (s *SegmentedSession) Finish(ctx context.Context, final FinalAudioChunk) error
func (*SegmentedSession) Mode ¶
func (s *SegmentedSession) Mode() AudioSessionMode
func (*SegmentedSession) Push ¶
func (s *SegmentedSession) Push(ctx context.Context, chunk AudioChunk) error
func (*SegmentedSession) RecommendedWaitTimeout ¶
func (s *SegmentedSession) RecommendedWaitTimeout() time.Duration
func (*SegmentedSession) Requirements ¶
func (s *SegmentedSession) Requirements() InputRequirements
type SegmentedSessionConfig ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func NewSession(recognizer Recognizer, aligner *Aligner, cfg SessionConfig) (*Session, error)
func (*Session) AddSegment ¶
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Done is closed when the session has produced its terminal completion state. It is independent from whether a caller is currently consuming Events.
func (*Session) SpeechEnded ¶
SpeechEnded rearms tail finalization for the latest submitted segment. It is useful when a long physical utterance has been split into multiple ASR segments before the upstream VAD emits its final speech_end event.
func (*Session) SpeechSplit ¶
SpeechSplit finalizes the latest submitted segment and starts a new evidence chain for speech that continues after an internally promoted boundary. Unlike SpeechStarted, it never keeps a short segment open for neighboring context.
type SessionConfig ¶
type SessionConfig struct {
SessionID string
SegmentStrategy SegmentRecognitionStrategy
Language string
LanguageHints []string
Context RecognitionContext
SampleRate int
Channels int
EventBuffer int
ContextSilence time.Duration
TailFinalizeSilence time.Duration
TailFinalizeResultWait time.Duration
ShortSegmentMaxDuration time.Duration
ShortSegmentNeighborWait time.Duration
MaxWindowDuration time.Duration
TailAnchorEnabled bool
}
type SpeechBoundary ¶
type SpeechBoundary struct {
Type SpeechBoundaryType
SourceSegmentIndex int
StartSample int64
EndSample int64
}
SpeechBoundary uses absolute sample positions and is deliberately independent from any concrete VAD package.
type SpeechBoundaryType ¶
type SpeechBoundaryType string
const ( SpeechBoundaryStart SpeechBoundaryType = "speech_start" SpeechBoundarySoft SpeechBoundaryType = "speech_soft_boundary" SpeechBoundaryEnd SpeechBoundaryType = "speech_end" )
type StreamingAudioChunk ¶
type StreamingCapabilities ¶
type StreamingContextUpdate ¶ added in v1.0.1
type StreamingContextUpdate struct {
Context RecognitionContext
StableTranscripts []string
}
StreamingContextUpdate contains the immutable request context and the latest provider-final transcripts. Providers may translate it to their own in-session context update protocol without exposing their transport.
type StreamingProvider ¶
type StreamingProvider interface {
Name() string
Model() string
StreamingCapabilities() StreamingCapabilities
Start(ctx context.Context, request StreamingRequest) (ProviderStream, error)
}
StreamingProvider creates one persistent provider-side ASR stream. It does not expose a concrete WebSocket implementation to the SDK consumer.
type StreamingRequest ¶
type StreamingRequest struct {
SessionID string
Language string
LanguageHints []string
Context RecognitionContext
SampleRate int
Channels int
Format AudioFormat
ServerVAD bool
}
type TextAlignment ¶
type TextAlignment struct {
PreviousStartByte int
CurrentEndByte int
Info AlignmentInfo
}
type TranscriptState ¶
type TranscriptState string
const ( TranscriptStatePreview TranscriptState = "preview" TranscriptStateProvisional TranscriptState = "provisional" TranscriptStateStable TranscriptState = "stable" TranscriptStateDegraded TranscriptState = "degraded" TranscriptStateDiscarded TranscriptState = "discarded" )
type TranscriptionRequest ¶
type TranscriptionResult ¶
type TranscriptionResult struct {
ProviderResult
RequestID string
}
type VLLMRealtimeConfig ¶
type VLLMRealtimeProvider ¶
type VLLMRealtimeProvider struct {
// contains filtered or unexported fields
}
func NewVLLMRealtimeProvider ¶
func NewVLLMRealtimeProvider(cfg VLLMRealtimeConfig) (*VLLMRealtimeProvider, error)
func (*VLLMRealtimeProvider) Model ¶
func (p *VLLMRealtimeProvider) Model() string
func (*VLLMRealtimeProvider) Name ¶
func (p *VLLMRealtimeProvider) Name() string
func (*VLLMRealtimeProvider) ServerVADEnabled ¶
func (p *VLLMRealtimeProvider) ServerVADEnabled() bool
func (*VLLMRealtimeProvider) Start ¶
func (p *VLLMRealtimeProvider) Start( ctx context.Context, request StreamingRequest, ) (ProviderStream, error)
func (*VLLMRealtimeProvider) StreamingCapabilities ¶
func (p *VLLMRealtimeProvider) StreamingCapabilities() StreamingCapabilities
type WindowResult ¶
type WindowResult struct {
RequestID string `json:"request_id"`
WindowIndex int `json:"window_index"`
Segments []SegmentRef `json:"segments"`
Text string `json:"text"`
DetectedLanguage string `json:"detected_language,omitempty"`
Provider string `json:"provider"`
Model string `json:"model"`
Words []Word `json:"words,omitempty"`
}
Source Files
¶
- aligner.go
- audio.go
- audio_session.go
- client.go
- dashscope_inference_realtime.go
- elevenlabs_realtime.go
- errors.go
- gemini_realtime.go
- generic_http.go
- inworld_realtime.go
- language.go
- microsoft_http.go
- openai_realtime.go
- pcm16_resampler.go
- qwen_omni_realtime.go
- qwen_realtime.go
- realtime_session.go
- realtime_websocket.go
- scheduler.go
- segmented_session.go
- session.go
- streaming_provider.go
- types.go
- vllm_realtime.go