@@ -133,22 +133,31 @@ export default class Speech {
133133 return TurboSpeech . isSpeaking ( ) ;
134134 }
135135 /**
136- * Speaks text using current global options
136+ * Speaks text using current global options, or per-utterance options if provided.
137137 * @param text - The text to synthesize
138+ * @param options - Optional voice options overriding global settings for this utterance
138139 * @returns Promise<string> Resolves with utterance ID when the utterance is queued
139140 * @throws If text is null or undefined
140141 * @example
141142 * const id = await Speech.speak('Hello, world!');
143+ * // Or with per-utterance options:
144+ * const id2 = await Speech.speak('Hello!', { pitch: 1.5, rate: 0.8 });
142145 * // Later, use this ID to track events:
143146 * Speech.onFinish(({id: eventId}) => {
144147 * if (eventId === id) console.log('My speech finished');
145148 * });
146149 */
147- public static speak ( text : string ) : Promise < string > {
150+ public static speak ( text : string ) : Promise < string > ;
151+ public static speak ( text : string , options : VoiceOptions ) : Promise < string > ;
152+ public static speak ( text : string , options ?: VoiceOptions ) : Promise < string > {
153+ if ( options !== undefined ) {
154+ return TurboSpeech . speakWithOptions ( text , options ) ;
155+ }
148156 return TurboSpeech . speak ( text ) ;
149157 }
150158 /**
151159 * Speaks text with custom options for this utterance only. Uses global options for any settings not provided.
160+ * @deprecated Use `Speech.speak(text, options)` instead.
152161 * @param text - The text to synthesize
153162 * @param options - Voice options overriding global settings
154163 * @returns Promise<string> Resolves with utterance ID when the utterance is queued
0 commit comments