@ztimson/utils 0.28.8 → 0.28.10

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/string.d.ts CHANGED
@@ -84,6 +84,12 @@ export declare function pad(text: any, length: number, char?: string, start?: bo
84
84
  * @return {string}
85
85
  */
86
86
  export declare function pascalCase(str?: string): string;
87
+ /**
88
+ * Remove all emojis from a string
89
+ * @param {string} str Input string with emojis
90
+ * @returns {string} Sanitized string without emojis
91
+ */
92
+ export declare function removeEmojis(str: string): string;
87
93
  /**
88
94
  * Generate a random hexadecimal value
89
95
  *
package/dist/tts.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ export declare class TTS {
2
+ private static readonly QUALITY_PATTERNS;
3
+ private _currentUtterance;
4
+ private _voicesLoaded;
5
+ private _isStopping;
6
+ private _rate;
7
+ get rate(): number;
8
+ set rate(value: number);
9
+ private _pitch;
10
+ get pitch(): number;
11
+ set pitch(value: number);
12
+ private _volume;
13
+ get volume(): number;
14
+ set volume(value: number);
15
+ private _voice;
16
+ get voice(): SpeechSynthesisVoice | undefined;
17
+ set voice(value: SpeechSynthesisVoice | undefined);
18
+ /** Create a TTS instance with optional configuration */
19
+ constructor(config?: {
20
+ rate?: number;
21
+ pitch?: number;
22
+ volume?: number;
23
+ voice?: SpeechSynthesisVoice | null;
24
+ });
25
+ /** Initializes voice loading and sets default voice if needed */
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
+ private static bestVoice;
33
+ /** Cleans text for TTS by removing emojis, markdown and code block */
34
+ private static cleanText;
35
+ /** Creates a speech utterance with current options */
36
+ private createUtterance;
37
+ /** Speaks text and returns a Promise which resolves once complete */
38
+ speak(text: string): Promise<void>;
39
+ /** Stops all TTS */
40
+ 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
+ speakStream(): {
54
+ next: (text: string) => void;
55
+ done: () => Promise<void>;
56
+ };
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/utils",
3
- "version": "0.28.8",
3
+ "version": "0.28.10",
4
4
  "description": "Utility library",
5
5
  "author": "Zak Timson",
6
6
  "license": "MIT",