@elevenlabs/client 0.15.0 → 0.15.1

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.
@@ -0,0 +1 @@
1
+ export declare function addLibsamplerateModule(context: AudioContext, customPath?: string): Promise<void>;
@@ -9,7 +9,7 @@ export declare class Output {
9
9
  readonly gain: GainNode;
10
10
  readonly worklet: AudioWorkletNode;
11
11
  readonly audioElement: HTMLAudioElement;
12
- static create({ sampleRate, format, outputDeviceId, workletPaths, }: FormatConfig & OutputConfig & AudioWorkletConfig): Promise<Output>;
12
+ static create({ sampleRate, format, outputDeviceId, workletPaths, libsampleratePath, }: FormatConfig & OutputConfig & AudioWorkletConfig): Promise<Output>;
13
13
  private constructor();
14
14
  setOutputDevice(deviceId?: string): Promise<void>;
15
15
  close(): Promise<void>;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "0.15.0";
1
+ export declare const PACKAGE_VERSION = "0.15.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevenlabs/client",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "ElevenLabs JavaScript Client Library",
5
5
  "main": "./dist/lib.umd.js",
6
6
  "module": "./dist/lib.module.js",
@@ -4,7 +4,7 @@
4
4
  * USED BY @elevenlabs/client
5
5
  */
6
6
 
7
- const decodeTable = [0,132,396,924,1980,4092,8316,16764];
7
+ const decodeTable = [0, 132, 396, 924, 1980, 4092, 8316, 16764];
8
8
 
9
9
  function decodeSample(muLawSample) {
10
10
  let sign;
@@ -12,10 +12,10 @@ function decodeSample(muLawSample) {
12
12
  let mantissa;
13
13
  let sample;
14
14
  muLawSample = ~muLawSample;
15
- sign = (muLawSample & 0x80);
15
+ sign = muLawSample & 0x80;
16
16
  exponent = (muLawSample >> 4) & 0x07;
17
- mantissa = muLawSample & 0x0F;
18
- sample = decodeTable[exponent] + (mantissa << (exponent+3));
17
+ mantissa = muLawSample & 0x0f;
18
+ sample = decodeTable[exponent] + (mantissa << (exponent + 3));
19
19
  if (sign !== 0) sample = -sample;
20
20
 
21
21
  return sample;
@@ -29,11 +29,20 @@ class AudioConcatProcessor extends AudioWorkletProcessor {
29
29
  this.currentBuffer = null;
30
30
  this.wasInterrupted = false;
31
31
  this.finished = false;
32
-
32
+
33
33
  this.port.onmessage = ({ data }) => {
34
34
  switch (data.type) {
35
35
  case "setFormat":
36
36
  this.format = data.format;
37
+ if (globalThis.LibSampleRate && sampleRate !== data.sampleRate) {
38
+ globalThis.LibSampleRate.create(
39
+ 1,
40
+ data.sampleRate,
41
+ sampleRate
42
+ ).then(resampler => {
43
+ this.resampler = resampler;
44
+ });
45
+ }
37
46
  break;
38
47
  case "buffer":
39
48
  this.wasInterrupted = false;
@@ -65,6 +74,9 @@ class AudioConcatProcessor extends AudioWorkletProcessor {
65
74
  break;
66
75
  }
67
76
  this.currentBuffer = this.buffers.shift();
77
+ if (this.resampler) {
78
+ this.currentBuffer = this.resampler.full(this.currentBuffer);
79
+ }
68
80
  this.cursor = 0;
69
81
  }
70
82