@elevenlabs/client 0.15.0 → 0.15.2

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.
@@ -47,6 +47,7 @@ export type BaseSessionConfig = {
47
47
  connectionDelay?: DelayConfig;
48
48
  textOnly?: boolean;
49
49
  userId?: string;
50
+ environment?: string;
50
51
  };
51
52
  export type ConnectionType = "websocket" | "webrtc";
52
53
  export type PublicSessionConfig = BaseSessionConfig & {
@@ -0,0 +1 @@
1
+ export declare function addLibsamplerateModule(context: AudioContext, customPath?: string): Promise<void>;
@@ -30,5 +30,6 @@ export type ContextualUpdateEvent = Outgoing.ContextualUpdateClientToOrchestrato
30
30
  export type UserMessageEvent = Outgoing.UserMessageClientToOrchestratorEvent;
31
31
  export type UserActivityEvent = Outgoing.UserActivityClientToOrchestratorEvent;
32
32
  export type MCPToolApprovalResultEvent = Outgoing.McpToolApprovalResultClientToOrchestratorEvent;
33
- export type OutgoingSocketEvent = PongEvent | UserAudioEvent | InitiationClientDataEvent | UserFeedbackEvent | ClientToolResultEvent | ContextualUpdateEvent | UserMessageEvent | UserActivityEvent | MCPToolApprovalResultEvent;
33
+ export type MultimodalMessageEvent = Outgoing.MultimodalMessageClientToOrchestratorEvent;
34
+ export type OutgoingSocketEvent = PongEvent | UserAudioEvent | InitiationClientDataEvent | UserFeedbackEvent | ClientToolResultEvent | ContextualUpdateEvent | UserMessageEvent | UserActivityEvent | MCPToolApprovalResultEvent | MultimodalMessageEvent;
34
35
  export declare function isValidSocketEvent(event: any): event is IncomingSocketEvent;
@@ -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.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevenlabs/client",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "description": "ElevenLabs JavaScript Client Library",
5
5
  "main": "./dist/lib.umd.js",
6
6
  "module": "./dist/lib.module.js",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "livekit-client": "^2.11.4",
42
- "@elevenlabs/types": "0.6.0"
42
+ "@elevenlabs/types": "0.6.1"
43
43
  },
44
44
  "scripts": {
45
45
  "generate-version": "printf \"// This file is auto-generated during build\\nexport const PACKAGE_VERSION = \\\"%s\\\";\\n\" \"$npm_package_version\" > src/version.ts",
@@ -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