uneeq-js 3.10.4 → 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,129 @@
1
+ import { type Subject } from 'rxjs';
2
+ import { type UneeqMessage } from './types/UneeqMessages';
3
+ import { type DataChannelMessage } from './webrtc-data-channel/DataChannelMessage';
4
+ import { type PromptMetadata } from './types/PromptMetadata';
5
+ import { type SpeechRecognitionInterface } from './types/SpeechRecognitionInterface';
6
+ export interface DeepgramFluxSTTOptions {
7
+ connectionUrl: string;
8
+ jwtToken: string;
9
+ sessionId: string;
10
+ model?: string;
11
+ language?: string;
12
+ /** End-of-turn confidence threshold (0.5-0.9). @default 0.7 */
13
+ eotThreshold?: number;
14
+ /** Eager end-of-turn threshold (0.3-0.9). */
15
+ eagerEotThreshold?: number;
16
+ /** End-of-turn timeout in ms. */
17
+ eotTimeoutMs?: number;
18
+ /** Send ChatPrompt on EagerEndOfTurn (lower latency, risk of incomplete). @default true */
19
+ useEagerEndOfTurn?: boolean;
20
+ /**
21
+ * Keyterms to boost in transcription results.
22
+ */
23
+ keyterms?: string[];
24
+ echoCancellation?: boolean;
25
+ noiseSuppression?: boolean;
26
+ autoGainControl?: boolean;
27
+ microphoneDeviceId?: string;
28
+ promptMetadata: PromptMetadata;
29
+ messages: Subject<UneeqMessage>;
30
+ sendMessage: (msg: DataChannelMessage) => void;
31
+ }
32
+ export declare class DeepgramFluxSTT implements SpeechRecognitionInterface {
33
+ private readonly options;
34
+ private connection;
35
+ private state;
36
+ private shouldReconnect;
37
+ private stream;
38
+ private audioContext;
39
+ private workletNode;
40
+ private reconnectAttempts;
41
+ private reconnectDelay;
42
+ private reconnectTimeoutId;
43
+ private digitalHumanSpeaking;
44
+ private isUserCurrentlySpeaking;
45
+ private isUiShowingSpeaking;
46
+ private eagerPromptSentForTurn;
47
+ private safetyNetTimeoutId;
48
+ private audioChunksSent;
49
+ constructor(options: DeepgramFluxSTTOptions);
50
+ startRecognition(): Promise<void>;
51
+ stopRecognition(): Promise<void>;
52
+ pause(): Promise<boolean>;
53
+ resume(): Promise<boolean>;
54
+ setChatMetadata(chatMetadata: PromptMetadata): void;
55
+ private connect;
56
+ private disconnect;
57
+ private scheduleReconnect;
58
+ private resetReconnectionState;
59
+ private clearReconnectTimeout;
60
+ private getToken;
61
+ private startMicrophone;
62
+ private stopMicrophone;
63
+ private setupEventHandlers;
64
+ /**
65
+ * Primary handler for Flux v2 TurnInfo events.
66
+ * Routes to specific handlers based on the turn event type.
67
+ */
68
+ private handleTurnInfo;
69
+ /**
70
+ * StartOfTurn: User has begun speaking.
71
+ * Emit UserStartedSpeaking and send UserSpeaking(Start) to data channel.
72
+ */
73
+ private handleStartOfTurn;
74
+ /**
75
+ * Update: Interim transcript during the current turn.
76
+ *
77
+ * This is also the interruption trigger: the first Update with real transcript
78
+ * while the avatar is speaking sends StopSpeaking immediately. No word thresholds —
79
+ * Flux's own turn detection is the source of truth.
80
+ */
81
+ private handleUpdate;
82
+ /**
83
+ * EagerEndOfTurn: Model predicts the user might be done speaking.
84
+ * If useEagerEndOfTurn is enabled, send ChatPrompt immediately for lower latency.
85
+ *
86
+ * If the avatar is still speaking (interruption disabled or Update hasn't fired yet),
87
+ * the prompt is discarded — we can't send competing prompts while the avatar talks.
88
+ */
89
+ private handleEagerEndOfTurn;
90
+ /**
91
+ * TurnResumed: Model detects the user continued speaking after an EagerEndOfTurn.
92
+ * If an eager prompt was already sent, log a warning (can't unsend).
93
+ */
94
+ private handleTurnResumed;
95
+ /**
96
+ * EndOfTurn: Model has determined the user has finished speaking.
97
+ *
98
+ * If the avatar is still speaking (interruption disabled), the prompt is discarded.
99
+ * Otherwise, cancel any in-flight eager prompt and send the definitive transcript.
100
+ */
101
+ private handleEndOfTurn;
102
+ /**
103
+ * Handle FatalError from v2 API.
104
+ */
105
+ private handleFatalError;
106
+ /**
107
+ * Calculate average confidence from word-level data, or return a default.
108
+ */
109
+ private calculateWordConfidence;
110
+ private handleAppMessages;
111
+ private handleConnectionOpen;
112
+ private handleConnectionClose;
113
+ private handleError;
114
+ private sendChatPrompt;
115
+ private handleSpeakingEnd;
116
+ /**
117
+ * Reset the safety net timer. Called on every TurnInfo event.
118
+ * If the user is in a speaking state and no events arrive for SAFETY_NET_TIMEOUT_MS,
119
+ * the speaking indicators are reset to prevent the UI getting stuck.
120
+ */
121
+ private resetSafetyNet;
122
+ private clearSafetyNet;
123
+ /**
124
+ * Reset speaking states and send appropriate stop messages.
125
+ */
126
+ private resetSpeakingStates;
127
+ private dataChannelMsgSend;
128
+ private clientMsgSend;
129
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -6,5 +6,6 @@ export type { SpeechTranscriptionResult } from './types/SpeechTranscriptionResul
6
6
  export { CameraAnchorDistance, CameraAnchorHorizontal } from './webrtc-data-channel/messages/CameraAnchor';
7
7
  export { LogLevel } from './types/LogLevel';
8
8
  export type { DeepgramSTTOptions } from './deepgram-stt';
9
+ export type { DeepgramFluxSTTOptions } from './deepgram-flux-stt';
9
10
  export type { NetworkQualityMetrics, NetworkIndicatorConfig } from './types/NetworkQuality';
10
11
  export { NetworkQualityLevel, NetworkIndicatorPosition, NetworkIndicatorVisibility, NetworkIndicatorPopupTrigger } from './types/NetworkQuality';