@ztimson/utils 0.28.11 → 0.28.13
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.
- package/dist/index.cjs +71 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +71 -24
- package/dist/index.mjs.map +1 -1
- package/dist/tts.d.ts +2 -23
- package/package.json +1 -1
package/dist/tts.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare class TTS {
|
|
2
2
|
private static readonly QUALITY_PATTERNS;
|
|
3
|
+
private static _errorHandlerInstalled;
|
|
3
4
|
private _currentUtterance;
|
|
4
5
|
private _voicesLoaded;
|
|
5
6
|
private _stoppedUtterances;
|
|
@@ -15,41 +16,19 @@ export declare class TTS {
|
|
|
15
16
|
private _voice;
|
|
16
17
|
get voice(): SpeechSynthesisVoice | undefined;
|
|
17
18
|
set voice(value: SpeechSynthesisVoice | undefined);
|
|
18
|
-
/** Create a TTS instance with optional configuration */
|
|
19
19
|
constructor(config?: {
|
|
20
20
|
rate?: number;
|
|
21
21
|
pitch?: number;
|
|
22
22
|
volume?: number;
|
|
23
23
|
voice?: SpeechSynthesisVoice | null;
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
private static installErrorHandler;
|
|
26
26
|
private initializeVoices;
|
|
27
|
-
/**
|
|
28
|
-
* Selects the best available TTS voice, prioritizing high-quality options
|
|
29
|
-
* @param lang Speaking language
|
|
30
|
-
* @returns Highest quality voice
|
|
31
|
-
*/
|
|
32
27
|
private static bestVoice;
|
|
33
|
-
/** Cleans text for TTS by removing emojis, markdown and code block */
|
|
34
28
|
private static cleanText;
|
|
35
|
-
/** Creates a speech utterance with current options */
|
|
36
29
|
private createUtterance;
|
|
37
|
-
/** Speaks text and returns a Promise which resolves once complete */
|
|
38
30
|
speak(text: string): Promise<void>;
|
|
39
|
-
/** Stops all TTS */
|
|
40
31
|
stop(): void;
|
|
41
|
-
/**
|
|
42
|
-
* Initialize a stream that chunks text into sentences and speak them.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* const stream = tts.speakStream();
|
|
46
|
-
* stream.next("Hello ");
|
|
47
|
-
* stream.next("World. How");
|
|
48
|
-
* stream.next(" are you?");
|
|
49
|
-
* await stream.done();
|
|
50
|
-
*
|
|
51
|
-
* @returns Object with next function for passing chunk of streamed text and done for completing the stream
|
|
52
|
-
*/
|
|
53
32
|
speakStream(): {
|
|
54
33
|
next: (text: string) => void;
|
|
55
34
|
done: () => Promise<void>;
|