hume 0.15.8 → 0.15.9

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.
@@ -10,11 +10,11 @@ export declare namespace HumeClient {
10
10
  }
11
11
  export declare class HumeClient {
12
12
  protected readonly _options: HumeClient.Options;
13
- protected _tts: Tts | undefined;
14
13
  protected _empathicVoice: EmpathicVoice | undefined;
14
+ protected _tts: Tts | undefined;
15
15
  protected _expressionMeasurement: ExpressionMeasurement | undefined;
16
16
  constructor(_options?: HumeClient.Options);
17
- get tts(): Tts;
18
17
  get empathicVoice(): EmpathicVoice;
18
+ get tts(): Tts;
19
19
  get expressionMeasurement(): ExpressionMeasurement;
20
20
  }
@@ -45,20 +45,20 @@ class HumeClient {
45
45
  this._options = Object.assign(Object.assign({}, _options), { logging: core.logging.createLogger(_options === null || _options === void 0 ? void 0 : _options.logging), headers: (0, headers_js_1.mergeHeaders)({
46
46
  "X-Fern-Language": "JavaScript",
47
47
  "X-Fern-SDK-Name": "hume",
48
- "X-Fern-SDK-Version": "0.15.8",
49
- "User-Agent": "hume/0.15.8",
48
+ "X-Fern-SDK-Version": "0.15.9",
49
+ "User-Agent": "hume/0.15.9",
50
50
  "X-Fern-Runtime": core.RUNTIME.type,
51
51
  "X-Fern-Runtime-Version": core.RUNTIME.version,
52
52
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
53
53
  }
54
- get tts() {
55
- var _a;
56
- return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Client_js_3.Tts(this._options)));
57
- }
58
54
  get empathicVoice() {
59
55
  var _a;
60
56
  return ((_a = this._empathicVoice) !== null && _a !== void 0 ? _a : (this._empathicVoice = new Client_js_1.EmpathicVoice(this._options)));
61
57
  }
58
+ get tts() {
59
+ var _a;
60
+ return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Client_js_3.Tts(this._options)));
61
+ }
62
62
  get expressionMeasurement() {
63
63
  var _a;
64
64
  return ((_a = this._expressionMeasurement) !== null && _a !== void 0 ? _a : (this._expressionMeasurement = new Client_js_2.ExpressionMeasurement(this._options)));
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.15.8";
1
+ export declare const SDK_VERSION = "0.15.9";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.15.8";
4
+ exports.SDK_VERSION = "0.15.9";
@@ -1,10 +1,24 @@
1
- import { Readable } from "stream";
2
1
  /**
3
- * SilenceFiller is a Readable stream that intersperses incoming audio data
2
+ * A minimal Writable-like interface that SilenceFiller can pipe to.
3
+ * This matches the subset of Node.js Writable that we need.
4
+ */
5
+ export interface PipeDestination {
6
+ write(chunk: Uint8Array): boolean;
7
+ end?(): void;
8
+ on?(event: "drain", listener: () => void): this;
9
+ once?(event: "drain", listener: () => void): this;
10
+ removeListener?(event: "drain", listener: () => void): this;
11
+ }
12
+ type EventListener = (...args: unknown[]) => void;
13
+ /**
14
+ * SilenceFiller is a pipeable stream that intersperses incoming audio data
4
15
  * with bytes of silence. This is important in some cases to keep an audio
5
16
  * stream "alive". Audio players, such as ffmpeg, can interpret inactivity as
6
17
  * meaning the stream is ended, or disconnected.
7
18
  *
19
+ * This implementation does not depend on Node.js built-ins and can work in
20
+ * any JavaScript environment, while still being pipeable to Node.js streams.
21
+ *
8
22
  * @example
9
23
  * ```typescript
10
24
  * import { SilenceFiller } from 'hume';
@@ -29,12 +43,15 @@ import { Readable } from "stream";
29
43
  * await silenceFiller.endStream();
30
44
  * ```
31
45
  */
32
- export declare class SilenceFiller extends Readable {
46
+ export declare class SilenceFiller {
33
47
  private unclockedSilenceFiller;
34
48
  private isStarted;
35
- private pushInterval;
49
+ private pushIntervalId;
36
50
  private bytesPerSample;
37
51
  private pushIntervalMs;
52
+ private destination;
53
+ private eventListeners;
54
+ private ended;
38
55
  /**
39
56
  * Creates a new SilenceFiller instance.
40
57
  *
@@ -46,16 +63,52 @@ export declare class SilenceFiller extends Readable {
46
63
  * playback will take longer to start.
47
64
  */
48
65
  constructor(pushIntervalMs?: number, sampleRate?: number, bytesPerSample?: number, bufferSize?: number);
66
+ /**
67
+ * Pipes the output of this SilenceFiller to a writable destination.
68
+ *
69
+ * @param destination - The destination to pipe to (e.g., a Node.js Writable stream).
70
+ * @returns The destination, for chaining.
71
+ */
72
+ pipe<T extends PipeDestination>(destination: T): T;
73
+ /**
74
+ * Registers an event listener.
75
+ *
76
+ * @param event - The event name ('error', 'end').
77
+ * @param listener - The listener function.
78
+ * @returns This instance, for chaining.
79
+ */
80
+ on(event: string, listener: EventListener): this;
81
+ /**
82
+ * Registers a one-time event listener.
83
+ *
84
+ * @param event - The event name ('error', 'end').
85
+ * @param listener - The listener function.
86
+ * @returns This instance, for chaining.
87
+ */
88
+ once(event: string, listener: EventListener): this;
89
+ /**
90
+ * Removes an event listener.
91
+ *
92
+ * @param event - The event name.
93
+ * @param listener - The listener function to remove.
94
+ * @returns This instance, for chaining.
95
+ */
96
+ off(event: string, listener: EventListener): this;
97
+ /**
98
+ * Emits an event to all registered listeners.
99
+ *
100
+ * @param event - The event name.
101
+ * @param args - Arguments to pass to listeners.
102
+ */
103
+ private emit;
49
104
  /**
50
105
  * Writes audio data to the silence filler.
51
106
  *
52
- * @param audioBuffer - The audio buffer to write.
107
+ * @param audioBuffer - The audio buffer to write (Uint8Array or Buffer).
53
108
  */
54
- writeAudio(audioBuffer: Buffer): void;
109
+ writeAudio(audioBuffer: Uint8Array): void;
55
110
  private startPushInterval;
56
111
  private pushData;
57
- _read(): void;
58
- _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
59
112
  /**
60
113
  * Ends the stream and drains all remaining audio data.
61
114
  *
@@ -80,6 +133,7 @@ export declare class UnclockedSilenceFiller {
80
133
  private sampleRate;
81
134
  private bytesPerSample;
82
135
  constructor(bufferSize: number, sampleRate: number, bytesPerSample: number);
83
- writeAudio(audioBuffer: Buffer, timestamp: number): void;
84
- readAudio(timestamp: number): Buffer | null;
136
+ writeAudio(audioBuffer: Uint8Array, timestamp: number): void;
137
+ readAudio(timestamp: number): Uint8Array | null;
85
138
  }
139
+ export {};
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnclockedSilenceFiller = exports.SilenceFiller = void 0;
4
- const stream_1 = require("stream");
5
4
  /**
6
- * SilenceFiller is a Readable stream that intersperses incoming audio data
5
+ * SilenceFiller is a pipeable stream that intersperses incoming audio data
7
6
  * with bytes of silence. This is important in some cases to keep an audio
8
7
  * stream "alive". Audio players, such as ffmpeg, can interpret inactivity as
9
8
  * meaning the stream is ended, or disconnected.
10
9
  *
10
+ * This implementation does not depend on Node.js built-ins and can work in
11
+ * any JavaScript environment, while still being pipeable to Node.js streams.
12
+ *
11
13
  * @example
12
14
  * ```typescript
13
15
  * import { SilenceFiller } from 'hume';
@@ -32,7 +34,7 @@ const stream_1 = require("stream");
32
34
  * await silenceFiller.endStream();
33
35
  * ```
34
36
  */
35
- class SilenceFiller extends stream_1.Readable {
37
+ class SilenceFiller {
36
38
  /**
37
39
  * Creates a new SilenceFiller instance.
38
40
  *
@@ -44,17 +46,90 @@ class SilenceFiller extends stream_1.Readable {
44
46
  * playback will take longer to start.
45
47
  */
46
48
  constructor(pushIntervalMs = 5, sampleRate = 48000, bytesPerSample = 2, bufferSize = 9600) {
47
- super({ objectMode: false });
48
49
  this.isStarted = false;
49
- this.pushInterval = null;
50
+ this.pushIntervalId = null;
51
+ this.destination = null;
52
+ this.eventListeners = new Map();
53
+ this.ended = false;
50
54
  this.unclockedSilenceFiller = new UnclockedSilenceFiller(bufferSize, sampleRate, bytesPerSample);
51
55
  this.bytesPerSample = bytesPerSample;
52
56
  this.pushIntervalMs = pushIntervalMs;
53
57
  }
58
+ /**
59
+ * Pipes the output of this SilenceFiller to a writable destination.
60
+ *
61
+ * @param destination - The destination to pipe to (e.g., a Node.js Writable stream).
62
+ * @returns The destination, for chaining.
63
+ */
64
+ pipe(destination) {
65
+ this.destination = destination;
66
+ return destination;
67
+ }
68
+ /**
69
+ * Registers an event listener.
70
+ *
71
+ * @param event - The event name ('error', 'end').
72
+ * @param listener - The listener function.
73
+ * @returns This instance, for chaining.
74
+ */
75
+ on(event, listener) {
76
+ if (!this.eventListeners.has(event)) {
77
+ this.eventListeners.set(event, new Set());
78
+ }
79
+ this.eventListeners.get(event).add(listener);
80
+ return this;
81
+ }
82
+ /**
83
+ * Registers a one-time event listener.
84
+ *
85
+ * @param event - The event name ('error', 'end').
86
+ * @param listener - The listener function.
87
+ * @returns This instance, for chaining.
88
+ */
89
+ once(event, listener) {
90
+ const onceWrapper = (...args) => {
91
+ this.off(event, onceWrapper);
92
+ listener(...args);
93
+ };
94
+ return this.on(event, onceWrapper);
95
+ }
96
+ /**
97
+ * Removes an event listener.
98
+ *
99
+ * @param event - The event name.
100
+ * @param listener - The listener function to remove.
101
+ * @returns This instance, for chaining.
102
+ */
103
+ off(event, listener) {
104
+ const listeners = this.eventListeners.get(event);
105
+ if (listeners) {
106
+ listeners.delete(listener);
107
+ }
108
+ return this;
109
+ }
110
+ /**
111
+ * Emits an event to all registered listeners.
112
+ *
113
+ * @param event - The event name.
114
+ * @param args - Arguments to pass to listeners.
115
+ */
116
+ emit(event, ...args) {
117
+ const listeners = this.eventListeners.get(event);
118
+ if (listeners) {
119
+ for (const listener of listeners) {
120
+ try {
121
+ listener(...args);
122
+ }
123
+ catch (_a) {
124
+ // Ignore errors in listeners
125
+ }
126
+ }
127
+ }
128
+ }
54
129
  /**
55
130
  * Writes audio data to the silence filler.
56
131
  *
57
- * @param audioBuffer - The audio buffer to write.
132
+ * @param audioBuffer - The audio buffer to write (Uint8Array or Buffer).
58
133
  */
59
134
  writeAudio(audioBuffer) {
60
135
  const now = Date.now();
@@ -71,12 +146,12 @@ class SilenceFiller extends stream_1.Readable {
71
146
  }
72
147
  }
73
148
  startPushInterval() {
74
- this.pushInterval = setInterval(() => {
149
+ this.pushIntervalId = setInterval(() => {
75
150
  this.pushData();
76
151
  }, this.pushIntervalMs);
77
152
  }
78
153
  pushData() {
79
- if (!this.isStarted)
154
+ if (!this.isStarted || !this.destination)
80
155
  return;
81
156
  try {
82
157
  const now = Date.now();
@@ -86,7 +161,7 @@ class SilenceFiller extends stream_1.Readable {
86
161
  const alignedChunkSize = Math.floor(audioChunk.length / this.bytesPerSample) * this.bytesPerSample;
87
162
  if (alignedChunkSize > 0) {
88
163
  const chunk = audioChunk.subarray(0, alignedChunkSize);
89
- this.push(chunk);
164
+ this.destination.write(chunk);
90
165
  }
91
166
  }
92
167
  }
@@ -95,10 +170,6 @@ class SilenceFiller extends stream_1.Readable {
95
170
  this.emit("error", error);
96
171
  }
97
172
  }
98
- _read() { }
99
- _destroy(error, callback) {
100
- super._destroy(error, callback);
101
- }
102
173
  /**
103
174
  * Ends the stream and drains all remaining audio data.
104
175
  *
@@ -106,15 +177,20 @@ class SilenceFiller extends stream_1.Readable {
106
177
  */
107
178
  endStream() {
108
179
  return new Promise((resolve) => {
180
+ if (this.ended) {
181
+ resolve();
182
+ return;
183
+ }
184
+ this.ended = true;
109
185
  // Stop pushing data
110
- if (this.pushInterval) {
111
- clearInterval(this.pushInterval);
112
- this.pushInterval = null;
186
+ if (this.pushIntervalId) {
187
+ clearInterval(this.pushIntervalId);
188
+ this.pushIntervalId = null;
113
189
  }
114
190
  // Drain all remaining audio from SilenceFiller
115
191
  const now = Date.now();
116
192
  // Keep reading until no more audio is available
117
- while (true) {
193
+ while (this.destination) {
118
194
  const remainingChunk = this.unclockedSilenceFiller.readAudio(now);
119
195
  if (!remainingChunk || remainingChunk.length === 0) {
120
196
  break;
@@ -122,13 +198,11 @@ class SilenceFiller extends stream_1.Readable {
122
198
  const alignedChunkSize = Math.floor(remainingChunk.length / this.bytesPerSample) * this.bytesPerSample;
123
199
  if (alignedChunkSize > 0) {
124
200
  const chunk = remainingChunk.subarray(0, alignedChunkSize);
125
- this.push(chunk);
201
+ this.destination.write(chunk);
126
202
  }
127
203
  }
128
- this.push(null); // Signal end of stream
129
- this.once("end", () => {
130
- resolve();
131
- });
204
+ this.emit("end");
205
+ resolve();
132
206
  });
133
207
  }
134
208
  }
@@ -176,11 +250,11 @@ class UnclockedSilenceFiller {
176
250
  if (alignedBytesNeeded <= 0) {
177
251
  return null;
178
252
  }
179
- let chunk = Buffer.alloc(0);
253
+ let chunk = new Uint8Array(0);
180
254
  // Drain from queue until we have enough bytes
181
255
  while (chunk.length < alignedBytesNeeded && this.audioQueue.length > 0) {
182
256
  const nextBuffer = this.audioQueue.shift();
183
- chunk = Buffer.concat([chunk, nextBuffer]);
257
+ chunk = concatUint8Arrays(chunk, nextBuffer);
184
258
  this.totalBufferedBytes -= nextBuffer.length;
185
259
  }
186
260
  // If we have more than needed, put the excess back
@@ -192,8 +266,8 @@ class UnclockedSilenceFiller {
192
266
  }
193
267
  // Fill remaining with silence if needed
194
268
  if (chunk.length < alignedBytesNeeded) {
195
- const silenceNeeded = Buffer.alloc(alignedBytesNeeded - chunk.length, 0);
196
- chunk = Buffer.concat([chunk, silenceNeeded]);
269
+ const silenceNeeded = new Uint8Array(alignedBytesNeeded - chunk.length); // Uint8Array is zero-filled by default
270
+ chunk = concatUint8Arrays(chunk, silenceNeeded);
197
271
  }
198
272
  // Update total bytes sent
199
273
  this.totalBytesSent += chunk.length;
@@ -201,3 +275,12 @@ class UnclockedSilenceFiller {
201
275
  }
202
276
  }
203
277
  exports.UnclockedSilenceFiller = UnclockedSilenceFiller;
278
+ /**
279
+ * Concatenates two Uint8Arrays into a new Uint8Array.
280
+ */
281
+ function concatUint8Arrays(a, b) {
282
+ const result = new Uint8Array(a.length + b.length);
283
+ result.set(a, 0);
284
+ result.set(b, a.length);
285
+ return result;
286
+ }
@@ -12,4 +12,9 @@ export { ExpressionMeasurement } from "./expressionMeasurement/ExpressionMeasure
12
12
  export { EVIWebAudioPlayer } from "./EVIWebAudioPlayer.js";
13
13
  export type { EVIWebAudioPlayerFFTOptions, EVIWebAudioPlayerOptions } from "./EVIWebAudioPlayer.js";
14
14
  export { collate } from "./collate.js";
15
+ export { SilenceFiller } from "./SilenceFiller.js";
16
+ export type { PipeDestination } from "./SilenceFiller.js";
17
+ /**
18
+ * @deprecated SilenceFiller no longer requires dynamic import. Use `import { SilenceFiller } from 'hume'` directly.
19
+ */
15
20
  export declare const createSilenceFiller: () => Promise<typeof import("./SilenceFiller.js").SilenceFiller>;
@@ -42,7 +42,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
42
42
  });
43
43
  };
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.createSilenceFiller = exports.collate = exports.EVIWebAudioPlayer = exports.ExpressionMeasurement = exports.HumeClient = exports.getBrowserSupportedMimeType = exports.MimeType = exports.getAudioStream = exports.fetchAccessToken = exports.checkForAudioTracks = exports.ensureSingleValidAudioTrack = exports.convertBlobToBase64 = exports.convertBase64ToBlob = exports.base64Encode = exports.base64Decode = void 0;
45
+ exports.createSilenceFiller = exports.SilenceFiller = exports.collate = exports.EVIWebAudioPlayer = exports.ExpressionMeasurement = exports.HumeClient = exports.getBrowserSupportedMimeType = exports.MimeType = exports.getAudioStream = exports.fetchAccessToken = exports.checkForAudioTracks = exports.ensureSingleValidAudioTrack = exports.convertBlobToBase64 = exports.convertBase64ToBlob = exports.base64Encode = exports.base64Decode = void 0;
46
46
  var base64Decode_js_1 = require("./base64Decode.js");
47
47
  Object.defineProperty(exports, "base64Decode", { enumerable: true, get: function () { return base64Decode_js_1.base64Decode; } });
48
48
  var base64Encode_js_1 = require("./base64Encode.js");
@@ -70,12 +70,12 @@ var EVIWebAudioPlayer_js_1 = require("./EVIWebAudioPlayer.js");
70
70
  Object.defineProperty(exports, "EVIWebAudioPlayer", { enumerable: true, get: function () { return EVIWebAudioPlayer_js_1.EVIWebAudioPlayer; } });
71
71
  var collate_js_1 = require("./collate.js");
72
72
  Object.defineProperty(exports, "collate", { enumerable: true, get: function () { return collate_js_1.collate; } });
73
- // SilenceFiller extends from Node.JS Readable -- this should not be exported in non-nodeJS environments. Otherwise the bundle will crash in the browser.
73
+ var SilenceFiller_js_1 = require("./SilenceFiller.js");
74
+ Object.defineProperty(exports, "SilenceFiller", { enumerable: true, get: function () { return SilenceFiller_js_1.SilenceFiller; } });
75
+ /**
76
+ * @deprecated SilenceFiller no longer requires dynamic import. Use `import { SilenceFiller } from 'hume'` directly.
77
+ */
74
78
  const createSilenceFiller = () => __awaiter(void 0, void 0, void 0, function* () {
75
- var _a;
76
- if (typeof process === "undefined" || !((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
77
- throw new Error("SilenceFiller is only available in Node.js environments");
78
- }
79
79
  const { SilenceFiller } = yield Promise.resolve().then(() => __importStar(require("./SilenceFiller.js")));
80
80
  return SilenceFiller;
81
81
  });
@@ -10,11 +10,11 @@ export declare namespace HumeClient {
10
10
  }
11
11
  export declare class HumeClient {
12
12
  protected readonly _options: HumeClient.Options;
13
- protected _tts: Tts | undefined;
14
13
  protected _empathicVoice: EmpathicVoice | undefined;
14
+ protected _tts: Tts | undefined;
15
15
  protected _expressionMeasurement: ExpressionMeasurement | undefined;
16
16
  constructor(_options?: HumeClient.Options);
17
- get tts(): Tts;
18
17
  get empathicVoice(): EmpathicVoice;
18
+ get tts(): Tts;
19
19
  get expressionMeasurement(): ExpressionMeasurement;
20
20
  }
@@ -9,20 +9,20 @@ export class HumeClient {
9
9
  this._options = Object.assign(Object.assign({}, _options), { logging: core.logging.createLogger(_options === null || _options === void 0 ? void 0 : _options.logging), headers: mergeHeaders({
10
10
  "X-Fern-Language": "JavaScript",
11
11
  "X-Fern-SDK-Name": "hume",
12
- "X-Fern-SDK-Version": "0.15.8",
13
- "User-Agent": "hume/0.15.8",
12
+ "X-Fern-SDK-Version": "0.15.9",
13
+ "User-Agent": "hume/0.15.9",
14
14
  "X-Fern-Runtime": core.RUNTIME.type,
15
15
  "X-Fern-Runtime-Version": core.RUNTIME.version,
16
16
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
17
17
  }
18
- get tts() {
19
- var _a;
20
- return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Tts(this._options)));
21
- }
22
18
  get empathicVoice() {
23
19
  var _a;
24
20
  return ((_a = this._empathicVoice) !== null && _a !== void 0 ? _a : (this._empathicVoice = new EmpathicVoice(this._options)));
25
21
  }
22
+ get tts() {
23
+ var _a;
24
+ return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Tts(this._options)));
25
+ }
26
26
  get expressionMeasurement() {
27
27
  var _a;
28
28
  return ((_a = this._expressionMeasurement) !== null && _a !== void 0 ? _a : (this._expressionMeasurement = new ExpressionMeasurement(this._options)));
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.15.8";
1
+ export declare const SDK_VERSION = "0.15.9";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.15.8";
1
+ export const SDK_VERSION = "0.15.9";
@@ -1,10 +1,24 @@
1
- import { Readable } from "stream";
2
1
  /**
3
- * SilenceFiller is a Readable stream that intersperses incoming audio data
2
+ * A minimal Writable-like interface that SilenceFiller can pipe to.
3
+ * This matches the subset of Node.js Writable that we need.
4
+ */
5
+ export interface PipeDestination {
6
+ write(chunk: Uint8Array): boolean;
7
+ end?(): void;
8
+ on?(event: "drain", listener: () => void): this;
9
+ once?(event: "drain", listener: () => void): this;
10
+ removeListener?(event: "drain", listener: () => void): this;
11
+ }
12
+ type EventListener = (...args: unknown[]) => void;
13
+ /**
14
+ * SilenceFiller is a pipeable stream that intersperses incoming audio data
4
15
  * with bytes of silence. This is important in some cases to keep an audio
5
16
  * stream "alive". Audio players, such as ffmpeg, can interpret inactivity as
6
17
  * meaning the stream is ended, or disconnected.
7
18
  *
19
+ * This implementation does not depend on Node.js built-ins and can work in
20
+ * any JavaScript environment, while still being pipeable to Node.js streams.
21
+ *
8
22
  * @example
9
23
  * ```typescript
10
24
  * import { SilenceFiller } from 'hume';
@@ -29,12 +43,15 @@ import { Readable } from "stream";
29
43
  * await silenceFiller.endStream();
30
44
  * ```
31
45
  */
32
- export declare class SilenceFiller extends Readable {
46
+ export declare class SilenceFiller {
33
47
  private unclockedSilenceFiller;
34
48
  private isStarted;
35
- private pushInterval;
49
+ private pushIntervalId;
36
50
  private bytesPerSample;
37
51
  private pushIntervalMs;
52
+ private destination;
53
+ private eventListeners;
54
+ private ended;
38
55
  /**
39
56
  * Creates a new SilenceFiller instance.
40
57
  *
@@ -46,16 +63,52 @@ export declare class SilenceFiller extends Readable {
46
63
  * playback will take longer to start.
47
64
  */
48
65
  constructor(pushIntervalMs?: number, sampleRate?: number, bytesPerSample?: number, bufferSize?: number);
66
+ /**
67
+ * Pipes the output of this SilenceFiller to a writable destination.
68
+ *
69
+ * @param destination - The destination to pipe to (e.g., a Node.js Writable stream).
70
+ * @returns The destination, for chaining.
71
+ */
72
+ pipe<T extends PipeDestination>(destination: T): T;
73
+ /**
74
+ * Registers an event listener.
75
+ *
76
+ * @param event - The event name ('error', 'end').
77
+ * @param listener - The listener function.
78
+ * @returns This instance, for chaining.
79
+ */
80
+ on(event: string, listener: EventListener): this;
81
+ /**
82
+ * Registers a one-time event listener.
83
+ *
84
+ * @param event - The event name ('error', 'end').
85
+ * @param listener - The listener function.
86
+ * @returns This instance, for chaining.
87
+ */
88
+ once(event: string, listener: EventListener): this;
89
+ /**
90
+ * Removes an event listener.
91
+ *
92
+ * @param event - The event name.
93
+ * @param listener - The listener function to remove.
94
+ * @returns This instance, for chaining.
95
+ */
96
+ off(event: string, listener: EventListener): this;
97
+ /**
98
+ * Emits an event to all registered listeners.
99
+ *
100
+ * @param event - The event name.
101
+ * @param args - Arguments to pass to listeners.
102
+ */
103
+ private emit;
49
104
  /**
50
105
  * Writes audio data to the silence filler.
51
106
  *
52
- * @param audioBuffer - The audio buffer to write.
107
+ * @param audioBuffer - The audio buffer to write (Uint8Array or Buffer).
53
108
  */
54
- writeAudio(audioBuffer: Buffer): void;
109
+ writeAudio(audioBuffer: Uint8Array): void;
55
110
  private startPushInterval;
56
111
  private pushData;
57
- _read(): void;
58
- _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
59
112
  /**
60
113
  * Ends the stream and drains all remaining audio data.
61
114
  *
@@ -80,6 +133,7 @@ export declare class UnclockedSilenceFiller {
80
133
  private sampleRate;
81
134
  private bytesPerSample;
82
135
  constructor(bufferSize: number, sampleRate: number, bytesPerSample: number);
83
- writeAudio(audioBuffer: Buffer, timestamp: number): void;
84
- readAudio(timestamp: number): Buffer | null;
136
+ writeAudio(audioBuffer: Uint8Array, timestamp: number): void;
137
+ readAudio(timestamp: number): Uint8Array | null;
85
138
  }
139
+ export {};