@@ -20,6 +20,7 @@ import type { RawData } from 'ws';
2020import { WebSocket } from 'ws' ;
2121import type { STTEncoding , STTModels , VoiceFocus } from './models.js' ;
2222
23+ // Speech models in the Universal-3 Pro family, which share the same parameter support.
2324const U3_PRO_MODELS = [ 'u3-rt-pro' , 'u3-rt-pro-beta-1' , 'universal-3-5-pro' ] as const ;
2425
2526function isU3ProModel ( model : STTModels ) : boolean {
@@ -72,11 +73,11 @@ export interface STTOptions {
7273 maxTurnSilence ?: number ;
7374 formatTurns ?: boolean ;
7475 keytermsPrompt ?: string [ ] ;
75- /** Only supported with the `u3-rt-pro` model family. */
76+ /** Only supported with the Universal-3 Pro model family. */
7677 prompt ?: string ;
77- /** Only supported with the `u3-rt-pro` model family. */
78+ /** Only supported with the Universal-3 Pro model family. */
7879 agentContext ?: string ;
79- /** Only supported with the `u3-rt-pro` model family. Set at connection time only. */
80+ /** Only supported with the Universal-3 Pro model family. Set at connection time only. */
8081 previousContextNTurns ?: number ;
8182 vadThreshold ?: number ;
8283 /**
@@ -95,8 +96,8 @@ export interface STTOptions {
9596 /** Background audio suppression aggressiveness, from 0.0 to 1.0. Connect-time only. */
9697 voiceFocusThreshold ?: number ;
9798 /**
98- * Accuracy/latency preset for u3-rt-pro : `min_latency`, `balanced`, or `max_accuracy`.
99- * Explicit silence, partials, or VAD options still take precedence over mode defaults.
99+ * Accuracy/latency preset for the Universal-3 Pro model family : `min_latency`, `balanced`,
100+ * or `max_accuracy`. Explicit turn- silence values still take precedence over mode defaults.
100101 */
101102 mode ?: 'min_latency' | 'balanced' | 'max_accuracy' ;
102103 baseUrl : string ;
@@ -132,8 +133,8 @@ export class STT extends stt.STT {
132133 } ) ;
133134
134135 if ( opts . speechModel === 'u3-pro' ) {
135- log ( ) . warn ( "'u3-pro' is deprecated, use 'u3-rt -pro' instead." ) ;
136- opts . speechModel = 'u3-rt -pro' ;
136+ log ( ) . warn ( "'u3-pro' is deprecated, use 'universal-3-5 -pro' instead." ) ;
137+ opts . speechModel = 'universal-3-5 -pro' ;
137138 }
138139
139140 const speechModel = opts . speechModel ?? defaultSTTOptions . speechModel ;
@@ -161,8 +162,8 @@ export class STT extends stt.STT {
161162 ) ;
162163 }
163164
164- // Minimize latency; matches LK 's end-of-turn detector well .
165- const minTurnSilence = opts . minTurnSilence ?? 100 ;
165+ // Minimize latency by default, but let AssemblyAI 's mode preset control silence tuning .
166+ const minTurnSilence = opts . minTurnSilence ?? ( opts . mode === undefined ? 100 : undefined ) ;
166167
167168 this . #opts = {
168169 ...defaultSTTOptions ,
@@ -296,11 +297,13 @@ export class SpeechStream extends stt.SpeechStream {
296297 }
297298
298299 async #connectWS( ) : Promise < WebSocket > {
299- // u3-rt-pro family models default both min and max silence to 100ms when unset.
300+ // Universal-3 Pro family models default both min and max silence to 100ms when unset.
301+ // When a mode preset is selected, leave them unset unless explicitly provided so the
302+ // server's per-mode silence tuning is not overridden by the latency-optimized default.
300303 let minSilence = this . #opts. minTurnSilence ;
301304 let maxSilence = this . #opts. maxTurnSilence ;
302305 if ( isU3ProModel ( this . #opts. speechModel ) ) {
303- if ( minSilence === undefined ) minSilence = 100 ;
306+ if ( minSilence === undefined && this . #opts . mode === undefined ) minSilence = 100 ;
304307 if ( maxSilence === undefined ) maxSilence = minSilence ;
305308 }
306309
0 commit comments