@@ -192,7 +192,6 @@ class WSConnectionPool {
192192 #attemptConnection( ) : Promise < WebSocket > {
193193 return new Promise ( ( resolve , reject ) => {
194194 const wsUrl = new URL ( 'tts/v1/voice:streamBidirectional' , this . #url) ;
195- // Ensure protocol is wss
196195 if ( wsUrl . protocol === 'https:' ) wsUrl . protocol = 'wss:' ;
197196 else if ( wsUrl . protocol === 'http:' ) wsUrl . protocol = 'ws:' ;
198197
@@ -224,7 +223,6 @@ class WSConnectionPool {
224223 const json = JSON . parse ( data . toString ( ) ) as InworldMessage ;
225224 const result = json . result ;
226225 if ( result ) {
227- // Try to find contextId in result or top level
228226 const contextId = result . contextId || json . contextId ;
229227 if ( contextId && this . #listeners. has ( contextId ) ) {
230228 this . #listeners. get ( contextId ) ! ( json ) ;
@@ -288,7 +286,7 @@ export class TTS extends tts.TTS {
288286 }
289287
290288 /**
291- * List all available voices.
289+ * List all available voices in the workspace associated with the API key .
292290 * @param language - Optional ISO 639-1 language code to filter voices (e.g., 'en', 'es', 'fr')
293291 */
294292 async listVoices ( language ?: string ) : Promise < Voice [ ] > {
@@ -327,10 +325,6 @@ export class TTS extends tts.TTS {
327325 this . #opts = { ...this . #opts, ...opts } ;
328326 if ( opts . apiKey ) {
329327 this . #authorization = `Basic ${ opts . apiKey } ` ;
330- // If API key changes, we might need to reset the pool or create a new one?
331- // For now, assume WS url doesn't change or we just create new pool if needed.
332- // But existing pool has hardcoded auth in constructor.
333- // Re-creating pool is safer.
334328 this . #pool. close ( ) ;
335329 this . #pool = new WSConnectionPool ( this . #opts. wsURL , this . #authorization) ;
336330 }
@@ -482,22 +476,16 @@ class SynthesizeStream extends tts.SynthesizeStream {
482476 if ( ! result ) return ;
483477
484478 if ( result . contextCreated ) {
485- // context created
486479 } else if ( result . contextClosed ) {
487480 resolveProcessing ( ) ;
488481 } else if ( result . audioChunk ) {
489482 if ( result . audioChunk . timestampInfo ) {
490- // Log word timestamps if available
491483 const tsInfo = result . audioChunk . timestampInfo ;
492484 if ( tsInfo . wordAlignment ) {
493485 const words = tsInfo . wordAlignment . words || [ ] ;
494486 const starts = tsInfo . wordAlignment . wordStartTimeSeconds || [ ] ;
495487 const ends = tsInfo . wordAlignment . wordEndTimeSeconds || [ ] ;
496488
497- for ( let i = 0 ; i < words . length ; i ++ ) {
498- // console.log(`[Inworld TTS] Word: "${words[i]}", Start: ${starts[i]}, End: ${ends[i]}`);
499- }
500-
501489 // eslint-disable-next-line @typescript-eslint/no-explicit-any
502490 ( this . #tts as any ) . emit ( 'alignment' , {
503491 requestId : this . #contextId,
@@ -521,7 +509,6 @@ class SynthesizeStream extends tts.SynthesizeStream {
521509 }
522510
523511 if ( result . audioChunk . audioContent ) {
524- // Some servers may return either nested audioContent or top-level
525512 const b64Content = result . audioChunk . audioContent || result . audioContent ;
526513 if ( b64Content ) {
527514 const audio = Buffer . from ( b64Content , 'base64' ) ;
0 commit comments