@elevenlabs/client 0.15.1 → 1.0.0-rc.0

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.
Files changed (160) hide show
  1. package/README.md +20 -836
  2. package/dist/BaseConversation.d.ts +10 -8
  3. package/dist/BaseConversation.d.ts.map +1 -0
  4. package/dist/BaseConversation.js +392 -0
  5. package/dist/BaseConversation.js.map +1 -0
  6. package/dist/InputController.d.ts +13 -0
  7. package/dist/InputController.d.ts.map +1 -0
  8. package/dist/InputController.js +2 -0
  9. package/dist/InputController.js.map +1 -0
  10. package/dist/OutputController.d.ts +12 -0
  11. package/dist/OutputController.d.ts.map +1 -0
  12. package/dist/OutputController.js +2 -0
  13. package/dist/OutputController.js.map +1 -0
  14. package/dist/TextConversation.d.ts +7 -0
  15. package/dist/TextConversation.d.ts.map +1 -0
  16. package/dist/TextConversation.js +53 -0
  17. package/dist/TextConversation.js.map +1 -0
  18. package/dist/VoiceConversation.d.ts +14 -12
  19. package/dist/VoiceConversation.d.ts.map +1 -0
  20. package/dist/VoiceConversation.js +225 -0
  21. package/dist/VoiceConversation.js.map +1 -0
  22. package/dist/index.d.ts +11 -6
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +20 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/internal.d.ts +8 -0
  27. package/dist/internal.d.ts.map +1 -0
  28. package/dist/internal.js +6 -0
  29. package/dist/internal.js.map +1 -0
  30. package/dist/lib.iife.js +23493 -0
  31. package/dist/lib.iife.js.map +1 -0
  32. package/dist/platform/VoiceSessionSetup.d.ts +35 -0
  33. package/dist/platform/VoiceSessionSetup.d.ts.map +1 -0
  34. package/dist/platform/VoiceSessionSetup.js +74 -0
  35. package/dist/platform/VoiceSessionSetup.js.map +1 -0
  36. package/dist/scribe/connection.d.ts +1 -0
  37. package/dist/scribe/connection.d.ts.map +1 -0
  38. package/dist/scribe/connection.js +363 -0
  39. package/dist/scribe/connection.js.map +1 -0
  40. package/dist/scribe/index.d.ts +1 -0
  41. package/dist/scribe/index.d.ts.map +1 -0
  42. package/dist/scribe/index.js +8 -0
  43. package/dist/scribe/index.js.map +1 -0
  44. package/dist/scribe/scribe.d.ts +1 -0
  45. package/dist/scribe/scribe.d.ts.map +1 -0
  46. package/dist/scribe/scribe.js +193 -0
  47. package/dist/scribe/scribe.js.map +1 -0
  48. package/dist/sourceInfo.d.ts +7 -0
  49. package/dist/sourceInfo.d.ts.map +1 -0
  50. package/dist/sourceInfo.js +9 -0
  51. package/dist/sourceInfo.js.map +1 -0
  52. package/dist/utils/BaseConnection.d.ts +2 -8
  53. package/dist/utils/BaseConnection.d.ts.map +1 -0
  54. package/dist/utils/BaseConnection.js +73 -0
  55. package/dist/utils/BaseConnection.js.map +1 -0
  56. package/dist/utils/ConnectionFactory.d.ts +1 -0
  57. package/dist/utils/ConnectionFactory.d.ts.map +1 -0
  58. package/dist/utils/ConnectionFactory.js +26 -0
  59. package/dist/utils/ConnectionFactory.js.map +1 -0
  60. package/dist/utils/WebRTCConnection.d.ts +6 -1
  61. package/dist/utils/WebRTCConnection.d.ts.map +1 -0
  62. package/dist/utils/WebRTCConnection.js +494 -0
  63. package/dist/utils/WebRTCConnection.js.map +1 -0
  64. package/dist/utils/WebSocketConnection.d.ts +8 -3
  65. package/dist/utils/WebSocketConnection.d.ts.map +1 -0
  66. package/dist/utils/WebSocketConnection.js +155 -0
  67. package/dist/utils/WebSocketConnection.js.map +1 -0
  68. package/dist/utils/applyDelay.d.ts +1 -0
  69. package/dist/utils/applyDelay.d.ts.map +1 -0
  70. package/dist/utils/applyDelay.js +18 -0
  71. package/dist/utils/applyDelay.js.map +1 -0
  72. package/dist/utils/attachConnectionToOutput.d.ts +5 -0
  73. package/dist/utils/attachConnectionToOutput.d.ts.map +1 -0
  74. package/dist/utils/attachConnectionToOutput.js +11 -0
  75. package/dist/utils/attachConnectionToOutput.js.map +1 -0
  76. package/dist/utils/attachInputToConnection.d.ts +6 -0
  77. package/dist/utils/attachInputToConnection.d.ts.map +1 -0
  78. package/dist/utils/attachInputToConnection.js +16 -0
  79. package/dist/utils/attachInputToConnection.js.map +1 -0
  80. package/dist/utils/audio.d.ts +1 -0
  81. package/dist/utils/audio.d.ts.map +1 -0
  82. package/dist/utils/audio.js +16 -0
  83. package/dist/utils/audio.js.map +1 -0
  84. package/dist/utils/audioConcatProcessor.generated.d.ts +1 -0
  85. package/dist/utils/audioConcatProcessor.generated.d.ts.map +1 -0
  86. package/{worklets/audioConcatProcessor.js → dist/utils/audioConcatProcessor.generated.js} +12 -18
  87. package/dist/utils/audioConcatProcessor.generated.js.map +1 -0
  88. package/dist/utils/compatibility.d.ts +1 -0
  89. package/dist/utils/compatibility.d.ts.map +1 -0
  90. package/dist/utils/compatibility.js +16 -0
  91. package/dist/utils/compatibility.js.map +1 -0
  92. package/dist/utils/connection.d.ts +11 -0
  93. package/dist/utils/connection.d.ts.map +1 -0
  94. package/dist/utils/connection.js +14 -0
  95. package/dist/utils/connection.js.map +1 -0
  96. package/dist/utils/createWorkletModuleLoader.d.ts +1 -0
  97. package/dist/utils/createWorkletModuleLoader.d.ts.map +1 -0
  98. package/dist/utils/createWorkletModuleLoader.js +43 -0
  99. package/dist/utils/createWorkletModuleLoader.js.map +1 -0
  100. package/dist/utils/errors.d.ts +1 -0
  101. package/dist/utils/errors.d.ts.map +1 -0
  102. package/dist/utils/errors.js +11 -0
  103. package/dist/utils/errors.js.map +1 -0
  104. package/dist/utils/events.d.ts +2 -3
  105. package/dist/utils/events.d.ts.map +1 -0
  106. package/dist/utils/events.js +4 -0
  107. package/dist/utils/events.js.map +1 -0
  108. package/dist/utils/input.d.ts +22 -11
  109. package/dist/utils/input.d.ts.map +1 -0
  110. package/dist/utils/input.js +181 -0
  111. package/dist/utils/input.js.map +1 -0
  112. package/dist/utils/location.d.ts +5 -0
  113. package/dist/utils/location.d.ts.map +1 -0
  114. package/dist/utils/location.js +31 -0
  115. package/dist/utils/location.js.map +1 -0
  116. package/dist/utils/mergeOptions.d.ts +11 -0
  117. package/dist/utils/mergeOptions.d.ts.map +1 -0
  118. package/dist/utils/mergeOptions.js +38 -0
  119. package/dist/utils/mergeOptions.js.map +1 -0
  120. package/dist/utils/output.d.ts +36 -10
  121. package/dist/utils/output.d.ts.map +1 -0
  122. package/dist/utils/output.js +127 -0
  123. package/dist/utils/output.js.map +1 -0
  124. package/dist/utils/overrides.d.ts +1 -0
  125. package/dist/utils/overrides.d.ts.map +1 -0
  126. package/dist/utils/overrides.js +40 -0
  127. package/dist/utils/overrides.js.map +1 -0
  128. package/dist/utils/postOverallFeedback.d.ts +1 -0
  129. package/dist/utils/postOverallFeedback.d.ts.map +1 -0
  130. package/dist/utils/postOverallFeedback.js +19 -0
  131. package/dist/utils/postOverallFeedback.js.map +1 -0
  132. package/dist/utils/rawAudioProcessor.generated.d.ts +1 -0
  133. package/dist/utils/rawAudioProcessor.generated.d.ts.map +1 -0
  134. package/{worklets/rawAudioProcessor.js → dist/utils/rawAudioProcessor.generated.js} +7 -1
  135. package/dist/utils/rawAudioProcessor.generated.js.map +1 -0
  136. package/dist/utils/scribeAudioProcessor.generated.d.ts +1 -0
  137. package/dist/utils/scribeAudioProcessor.generated.d.ts.map +1 -0
  138. package/{worklets/scribeAudioProcessor.js → dist/utils/scribeAudioProcessor.generated.js} +7 -1
  139. package/dist/utils/scribeAudioProcessor.generated.js.map +1 -0
  140. package/dist/version.d.ts +2 -1
  141. package/dist/version.d.ts.map +1 -0
  142. package/dist/version.js +3 -0
  143. package/dist/version.js.map +1 -0
  144. package/package.json +21 -15
  145. package/.turbo/turbo-build.log +0 -13
  146. package/.turbo/turbo-generate-version.log +0 -4
  147. package/.turbo/turbo-generate-worklets.log +0 -9
  148. package/.turbo/turbo-lint$colon$es.log +0 -6
  149. package/.turbo/turbo-lint$colon$prettier.log +0 -6
  150. package/CHANGELOG.md +0 -42
  151. package/dist/lib.cjs +0 -2
  152. package/dist/lib.cjs.map +0 -1
  153. package/dist/lib.modern.js +0 -2
  154. package/dist/lib.modern.js.map +0 -1
  155. package/dist/lib.module.js +0 -2
  156. package/dist/lib.module.js.map +0 -1
  157. package/dist/lib.umd.js +0 -2
  158. package/dist/lib.umd.js.map +0 -1
  159. package/dist/utils/addLibsamplerateModule.d.ts +0 -1
  160. package/scripts/generateWorklets.js +0 -59
@@ -0,0 +1,181 @@
1
+ import { loadRawAudioProcessor } from "./rawAudioProcessor.generated";
2
+ import { isIosDevice } from "./compatibility";
3
+ const LIBSAMPLERATE_JS = "https://cdn.jsdelivr.net/npm/@alexanderolsen/libsamplerate-js@2.1.2/dist/libsamplerate.worklet.js";
4
+ const defaultConstraints = {
5
+ echoCancellation: true,
6
+ noiseSuppression: true,
7
+ // Automatic gain control helps maintain a steady volume level with microphones: https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/autoGainControl
8
+ autoGainControl: true,
9
+ // Mono audio for better echo cancellation
10
+ channelCount: { ideal: 1 },
11
+ };
12
+ export class MediaDeviceInput {
13
+ context;
14
+ analyser;
15
+ worklet;
16
+ inputStream;
17
+ mediaStreamSource;
18
+ permissions;
19
+ onError;
20
+ static async create({ sampleRate, format, preferHeadphonesForIosDevices, inputDeviceId, workletPaths, libsampleratePath, onError, }) {
21
+ let context = null;
22
+ let inputStream = null;
23
+ try {
24
+ const options = {
25
+ sampleRate: { ideal: sampleRate },
26
+ ...defaultConstraints,
27
+ };
28
+ if (isIosDevice() && preferHeadphonesForIosDevices) {
29
+ const availableDevices = await window.navigator.mediaDevices.enumerateDevices();
30
+ const idealDevice = availableDevices.find(d =>
31
+ // cautious to include "bluetooth" in the search
32
+ // as might trigger bluetooth speakers
33
+ d.kind === "audioinput" &&
34
+ ["airpod", "headphone", "earphone"].find(keyword => d.label.toLowerCase().includes(keyword)));
35
+ if (idealDevice) {
36
+ options.deviceId = { ideal: idealDevice.deviceId };
37
+ }
38
+ }
39
+ if (inputDeviceId) {
40
+ options.deviceId =
41
+ MediaDeviceInput.getDeviceIdConstraint(inputDeviceId);
42
+ }
43
+ const supportsSampleRateConstraint = navigator.mediaDevices.getSupportedConstraints().sampleRate;
44
+ context = new window.AudioContext(supportsSampleRateConstraint ? { sampleRate } : {});
45
+ const analyser = context.createAnalyser();
46
+ if (!supportsSampleRateConstraint) {
47
+ // Use custom libsamplerate path if provided, otherwise fallback to CDN
48
+ const libsamplerateUrl = libsampleratePath || LIBSAMPLERATE_JS;
49
+ await context.audioWorklet.addModule(libsamplerateUrl);
50
+ }
51
+ await loadRawAudioProcessor(context.audioWorklet, workletPaths?.["rawAudioProcessor"]);
52
+ const constraints = { voiceIsolation: true, ...options };
53
+ inputStream = await navigator.mediaDevices.getUserMedia({
54
+ audio: constraints,
55
+ });
56
+ const source = context.createMediaStreamSource(inputStream);
57
+ const worklet = new AudioWorkletNode(context, "rawAudioProcessor");
58
+ worklet.port.postMessage({ type: "setFormat", format, sampleRate });
59
+ source.connect(analyser);
60
+ analyser.connect(worklet);
61
+ await context.resume();
62
+ const permissions = await navigator.permissions.query({
63
+ name: "microphone",
64
+ });
65
+ return new MediaDeviceInput(context, analyser, worklet, inputStream, source, permissions, onError);
66
+ }
67
+ catch (error) {
68
+ inputStream?.getTracks().forEach(track => {
69
+ track.stop();
70
+ });
71
+ context?.close();
72
+ throw error;
73
+ }
74
+ }
75
+ // Use { ideal } on iOS as a defensive measure - some iOS versions may not support { exact } for deviceId constraints
76
+ static getDeviceIdConstraint(deviceId) {
77
+ if (!deviceId) {
78
+ return undefined;
79
+ }
80
+ return isIosDevice() ? { ideal: deviceId } : { exact: deviceId };
81
+ }
82
+ muted = false;
83
+ constructor(context, analyser, worklet, inputStream, mediaStreamSource, permissions, onError = console.error) {
84
+ this.context = context;
85
+ this.analyser = analyser;
86
+ this.worklet = worklet;
87
+ this.inputStream = inputStream;
88
+ this.mediaStreamSource = mediaStreamSource;
89
+ this.permissions = permissions;
90
+ this.onError = onError;
91
+ this.permissions.addEventListener("change", this.handlePermissionsChange);
92
+ // Start the MessagePort to enable addEventListener to work
93
+ // (required when using addEventListener instead of onmessage)
94
+ this.worklet.port.start();
95
+ }
96
+ getAnalyser() {
97
+ return this.analyser;
98
+ }
99
+ isMuted() {
100
+ return this.muted;
101
+ }
102
+ addListener(listener) {
103
+ this.worklet.port.addEventListener("message", listener);
104
+ }
105
+ removeListener(listener) {
106
+ this.worklet.port.removeEventListener("message", listener);
107
+ }
108
+ forgetInputStreamAndSource() {
109
+ for (const track of this.inputStream.getTracks()) {
110
+ track.stop();
111
+ }
112
+ this.mediaStreamSource.disconnect();
113
+ }
114
+ async close() {
115
+ this.forgetInputStreamAndSource();
116
+ this.permissions.removeEventListener("change", this.handlePermissionsChange);
117
+ await this.context.close();
118
+ }
119
+ async setMuted(isMuted) {
120
+ this.muted = isMuted;
121
+ this.worklet.port.postMessage({ type: "setMuted", isMuted });
122
+ }
123
+ settingInput = false;
124
+ async setDevice(config) {
125
+ try {
126
+ if (this.settingInput) {
127
+ throw new Error("Input device is already being set");
128
+ }
129
+ this.settingInput = true;
130
+ // Extract inputDeviceId from config
131
+ const inputDeviceId = config?.inputDeviceId;
132
+ // Note: sampleRate, format, and preferHeadphonesForIosDevices cannot be
133
+ // changed on an existing input (would require recreating the AudioContext).
134
+ // These options are only used during initial MediaDeviceInput.create()
135
+ // Create new constraints with the specified device or use default
136
+ const options = {
137
+ ...defaultConstraints,
138
+ };
139
+ if (inputDeviceId) {
140
+ options.deviceId =
141
+ MediaDeviceInput.getDeviceIdConstraint(inputDeviceId);
142
+ }
143
+ // If inputDeviceId is undefined, don't set deviceId constraint - browser uses default
144
+ const constraints = { voiceIsolation: true, ...options };
145
+ // Get new media stream with the specified device before forgetting the old one
146
+ // this prevents unintended interruption of the audio stream in case the new stream isn't obtained
147
+ const newInputStream = await navigator.mediaDevices.getUserMedia({
148
+ audio: constraints,
149
+ });
150
+ this.forgetInputStreamAndSource();
151
+ // Replace the stream and create new source
152
+ this.inputStream = newInputStream;
153
+ this.mediaStreamSource =
154
+ this.context.createMediaStreamSource(newInputStream);
155
+ // Reconnect the audio graph
156
+ this.mediaStreamSource.connect(this.analyser);
157
+ }
158
+ catch (error) {
159
+ this.onError("Failed to switch input device:", error);
160
+ throw error;
161
+ }
162
+ finally {
163
+ this.settingInput = false;
164
+ }
165
+ }
166
+ handlePermissionsChange = () => {
167
+ if (this.permissions.state === "denied") {
168
+ this.onError("Microphone permission denied");
169
+ // TODO: Tell the user to grant permission in some other way
170
+ }
171
+ else if (!this.settingInput) {
172
+ // Let's try to reset the input device, but only if we're not already in the process of setting it
173
+ const [track] = this.inputStream.getAudioTracks();
174
+ const { deviceId } = track?.getSettings() ?? {};
175
+ this.setDevice({ inputDeviceId: deviceId }).catch(error => {
176
+ this.onError("Failed to reset input device after permission change:", error);
177
+ });
178
+ }
179
+ };
180
+ }
181
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQ9C,MAAM,gBAAgB,GACpB,mGAAmG,CAAC;AAEtG,MAAM,kBAAkB,GAAG;IACzB,gBAAgB,EAAE,IAAI;IACtB,gBAAgB,EAAE,IAAI;IACtB,oKAAoK;IACpK,eAAe,EAAE,IAAI;IACrB,0CAA0C;IAC1C,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;CAC3B,CAAC;AAUF,MAAM,OAAO,gBAAgB;IA4GR;IACA;IACA;IACT;IACA;IACA;IACA;IAjHH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EACzB,UAAU,EACV,MAAM,EACN,6BAA6B,EAC7B,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,OAAO,GAGW;QAClB,IAAI,OAAO,GAAwB,IAAI,CAAC;QACxC,IAAI,WAAW,GAAuB,IAAI,CAAC;QAE3C,IAAI,CAAC;YAC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@ -0,0 +1,5 @@
1
+ export type Location = "us" | "global" | "eu-residency" | "in-residency";
2
+ export declare function parseLocation(location?: string): Location;
3
+ export declare function getOriginForLocation(location: Location): string;
4
+ export declare function getLivekitUrlForLocation(location: Location): string;
5
+ //# sourceMappingURL=location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/utils/location.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,cAAc,GAAG,cAAc,CAAC;AAEzE,wBAAgB,aAAa,CAAC,QAAQ,GAAE,MAAa,GAAG,QAAQ,CAa/D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAS/D;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CASnE"}
@@ -0,0 +1,31 @@
1
+ export function parseLocation(location = "us") {
2
+ switch (location) {
3
+ case "eu-residency":
4
+ case "in-residency":
5
+ case "us":
6
+ case "global":
7
+ return location;
8
+ default:
9
+ console.warn(`[ElevenAgents] Invalid server-location: ${location}. Defaulting to "us"`);
10
+ return "us";
11
+ }
12
+ }
13
+ export function getOriginForLocation(location) {
14
+ const originMap = {
15
+ us: "wss://api.elevenlabs.io",
16
+ "eu-residency": "wss://api.eu.residency.elevenlabs.io",
17
+ "in-residency": "wss://api.in.residency.elevenlabs.io",
18
+ global: "wss://api.elevenlabs.io",
19
+ };
20
+ return originMap[location];
21
+ }
22
+ export function getLivekitUrlForLocation(location) {
23
+ const livekitUrlMap = {
24
+ us: "wss://livekit.rtc.elevenlabs.io",
25
+ "eu-residency": "wss://livekit.rtc.eu.residency.elevenlabs.io",
26
+ "in-residency": "wss://livekit.rtc.in.residency.elevenlabs.io",
27
+ global: "wss://livekit.rtc.elevenlabs.io",
28
+ };
29
+ return livekitUrlMap[location];
30
+ }
31
+ //# sourceMappingURL=location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/utils/location.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAC,WAAmB,IAAI;IACnD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,cAAc,CAAC;QACpB,KAAK,cAAc,CAAC;QACpB,KAAK,IAAI,CAAC;QACV,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,CAAC,IAAI,CACV,2CAA2C,QAAQ,sBAAsB,CAC1E,CAAC;YACF,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,QAAkB;IACrD,MAAM,SAAS,GAA6B;QAC1C,EAAE,EAAE,yBAAyB;QAC7B,cAAc,EAAE,sCAAsC;QACtD,cAAc,EAAE,sCAAsC;QACtD,MAAM,EAAE,yBAAyB;KAClC,CAAC;IAEF,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,QAAkB;IACzD,MAAM,aAAa,GAA6B;QAC9C,EAAE,EAAE,iCAAiC;QACrC,cAAc,EAAE,8CAA8C;QAC9D,cAAc,EAAE,8CAA8C;QAC9D,MAAM,EAAE,iCAAiC;KAC1C,CAAC;IAEF,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Merges multiple partial option objects into one.
3
+ *
4
+ * - Plain objects are deep-merged so that later configs can override
5
+ * individual nested fields without wiping unrelated ones.
6
+ * - Functions sharing the same key are composed: all are called in
7
+ * order (earliest config first) with the same arguments.
8
+ * - All other values are shallow-merged (last value wins).
9
+ */
10
+ export declare function mergeOptions<T extends Record<string, unknown>>(...configs: Array<Partial<T>>): T;
11
+ //# sourceMappingURL=mergeOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeOptions.d.ts","sourceRoot":"","sources":["../../src/utils/mergeOptions.ts"],"names":[],"mappings":"AA2BA;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,GAAG,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAC5B,CAAC,CAEH"}
@@ -0,0 +1,38 @@
1
+ function isPlainObject(value) {
2
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3
+ }
4
+ function deepMerge(...objects) {
5
+ return objects.reduce((acc, obj) => {
6
+ const result = { ...acc };
7
+ for (const key of Object.keys(obj)) {
8
+ const accVal = result[key];
9
+ const objVal = obj[key];
10
+ if (isPlainObject(accVal) && isPlainObject(objVal)) {
11
+ result[key] = deepMerge(accVal, objVal);
12
+ }
13
+ else if (typeof accVal === "function" && typeof objVal === "function") {
14
+ result[key] = ((...args) => {
15
+ accVal(...args);
16
+ objVal(...args);
17
+ });
18
+ }
19
+ else if (objVal !== undefined) {
20
+ result[key] = objVal;
21
+ }
22
+ }
23
+ return result;
24
+ }, {});
25
+ }
26
+ /**
27
+ * Merges multiple partial option objects into one.
28
+ *
29
+ * - Plain objects are deep-merged so that later configs can override
30
+ * individual nested fields without wiping unrelated ones.
31
+ * - Functions sharing the same key are composed: all are called in
32
+ * order (earliest config first) with the same arguments.
33
+ * - All other values are shallow-merged (last value wins).
34
+ */
35
+ export function mergeOptions(...configs) {
36
+ return deepMerge(...configs);
37
+ }
38
+ //# sourceMappingURL=mergeOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeOptions.js","sourceRoot":"","sources":["../../src/utils/mergeOptions.ts"],"names":[],"mappings":"AAAA,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,SAAS,CAChB,GAAG,OAAqB;IAExB,OAAO,OAAO,CAAC,MAAM,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;QAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAmB,EAAE,CAAC;YACrD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACxB,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAe,CAAC;YACxD,CAAC;iBAAM,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;gBACxE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE;oBACpC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;oBAChB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;gBAClB,CAAC,CAAe,CAAC;YACnB,CAAC;iBAAM,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAoB,CAAC;YACrC,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAO,CAAC,CAAC;AACd,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAG,OAA0B;IAE7B,OAAO,SAAS,CAAI,GAAG,OAAO,CAAC,CAAC;AAClC,CAAC"}
@@ -1,16 +1,42 @@
1
1
  import type { FormatConfig } from "./connection";
2
2
  import type { AudioWorkletConfig } from "../BaseConversation";
3
- export type OutputConfig = {
4
- outputDeviceId?: string;
3
+ import type { OutputController, OutputDeviceConfig } from "../OutputController";
4
+ export type OutputConfig = OutputDeviceConfig;
5
+ export type OutputAudioEvent = {
6
+ audio_base_64: string;
5
7
  };
6
- export declare class Output {
7
- readonly context: AudioContext;
8
- readonly analyser: AnalyserNode;
9
- readonly gain: GainNode;
10
- readonly worklet: AudioWorkletNode;
11
- readonly audioElement: HTMLAudioElement;
12
- static create({ sampleRate, format, outputDeviceId, workletPaths, libsampleratePath, }: FormatConfig & OutputConfig & AudioWorkletConfig): Promise<Output>;
8
+ export type OutputListener = (event: OutputAudioEvent) => void;
9
+ export type OutputEventTarget = {
10
+ addListener(listener: OutputListener): void;
11
+ removeListener(listener: OutputListener): void;
12
+ };
13
+ export type PlaybackStateEvent = MessageEvent<{
14
+ type: "process";
15
+ finished: boolean;
16
+ }>;
17
+ export type PlaybackListener = (event: PlaybackStateEvent) => void;
18
+ export type PlaybackEventTarget = {
19
+ addListener(listener: PlaybackListener): void;
20
+ removeListener(listener: PlaybackListener): void;
21
+ };
22
+ export declare class MediaDeviceOutput implements OutputController, PlaybackEventTarget {
23
+ private readonly context;
24
+ private readonly analyser;
25
+ private readonly gain;
26
+ private readonly worklet;
27
+ private readonly audioElement;
28
+ static create({ sampleRate, format, outputDeviceId, workletPaths, }: FormatConfig & OutputConfig & AudioWorkletConfig): Promise<MediaDeviceOutput>;
29
+ private volume;
30
+ private interrupted;
31
+ private interruptTimeout;
13
32
  private constructor();
14
- setOutputDevice(deviceId?: string): Promise<void>;
33
+ getAnalyser(): AnalyserNode;
34
+ addListener(listener: PlaybackListener): void;
35
+ removeListener(listener: PlaybackListener): void;
36
+ setVolume(volume: number): void;
37
+ playAudio(chunk: ArrayBuffer): void;
38
+ interrupt(resetDuration?: number): void;
39
+ setDevice(config?: Partial<FormatConfig> & OutputDeviceConfig): Promise<void>;
15
40
  close(): Promise<void>;
16
41
  }
42
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AACA,OAA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kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA8DjD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,gBAAgB,CAA8C;IAEtE,OAAO;IAYA,WAAW,IAAI,YAAY;IAI3B,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAI7C,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIhD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAKnC,SAAS,CAAC,aAAa,SAAO,GAAG,IAAI;IA2B/B,SAAS,CACpB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,GAClD,OAAO,CAAC,IAAI,CAAC;IAgBH,KAAK;CAcnB"}
@@ -0,0 +1,127 @@
1
+ import { loadAudioConcatProcessor } from "./audioConcatProcessor.generated";
2
+ export class MediaDeviceOutput {
3
+ context;
4
+ analyser;
5
+ gain;
6
+ worklet;
7
+ audioElement;
8
+ static async create({ sampleRate, format, outputDeviceId, workletPaths, }) {
9
+ let context = null;
10
+ let audioElement = null;
11
+ try {
12
+ context = new AudioContext({ sampleRate });
13
+ const analyser = context.createAnalyser();
14
+ const gain = context.createGain();
15
+ // Always create an audio element for device switching capability
16
+ audioElement = new Audio();
17
+ audioElement.src = "";
18
+ audioElement.load();
19
+ audioElement.autoplay = true;
20
+ audioElement.style.display = "none";
21
+ document.body.appendChild(audioElement);
22
+ // Create media stream destination to route audio to the element
23
+ const destination = context.createMediaStreamDestination();
24
+ audioElement.srcObject = destination.stream;
25
+ gain.connect(analyser);
26
+ analyser.connect(destination);
27
+ await loadAudioConcatProcessor(context.audioWorklet, workletPaths?.["audioConcatProcessor"]);
28
+ const worklet = new AudioWorkletNode(context, "audioConcatProcessor");
29
+ worklet.port.postMessage({ type: "setFormat", format });
30
+ worklet.connect(gain);
31
+ await context.resume();
32
+ // Set initial output device if provided
33
+ if (outputDeviceId && audioElement.setSinkId) {
34
+ await audioElement.setSinkId(outputDeviceId);
35
+ }
36
+ const newOutput = new MediaDeviceOutput(context, analyser, gain, worklet, audioElement);
37
+ return newOutput;
38
+ }
39
+ catch (error) {
40
+ // Clean up audio element from DOM
41
+ if (audioElement?.parentNode) {
42
+ audioElement.parentNode.removeChild(audioElement);
43
+ }
44
+ audioElement?.pause();
45
+ if (context && context.state !== "closed") {
46
+ await context.close();
47
+ }
48
+ throw error;
49
+ }
50
+ }
51
+ volume = 1;
52
+ interrupted = false;
53
+ interruptTimeout = null;
54
+ constructor(context, analyser, gain, worklet, audioElement) {
55
+ this.context = context;
56
+ this.analyser = analyser;
57
+ this.gain = gain;
58
+ this.worklet = worklet;
59
+ this.audioElement = audioElement;
60
+ // Start the MessagePort to enable addEventListener to work
61
+ // (required when using addEventListener instead of onmessage)
62
+ this.worklet.port.start();
63
+ }
64
+ getAnalyser() {
65
+ return this.analyser;
66
+ }
67
+ addListener(listener) {
68
+ this.worklet.port.addEventListener("message", listener);
69
+ }
70
+ removeListener(listener) {
71
+ this.worklet.port.removeEventListener("message", listener);
72
+ }
73
+ setVolume(volume) {
74
+ this.volume = volume;
75
+ this.gain.gain.value = volume;
76
+ }
77
+ playAudio(chunk) {
78
+ if (this.interrupted)
79
+ return;
80
+ this.worklet.port.postMessage({ type: "buffer", buffer: chunk });
81
+ }
82
+ interrupt(resetDuration = 2000) {
83
+ this.interrupted = true;
84
+ // Clear any existing timeout
85
+ if (this.interruptTimeout) {
86
+ clearTimeout(this.interruptTimeout);
87
+ this.interruptTimeout = null;
88
+ }
89
+ // Send interrupt message to worklet to flush queued buffers
90
+ this.worklet.port.postMessage({ type: "interrupt" });
91
+ // Fade out audio gain
92
+ this.gain.gain.exponentialRampToValueAtTime(0.0001, this.context.currentTime + resetDuration / 1000);
93
+ // After fade completes, restore volume and accept new audio
94
+ this.interruptTimeout = setTimeout(() => {
95
+ this.interrupted = false;
96
+ this.gain.gain.value = this.volume;
97
+ this.worklet.port.postMessage({ type: "clearInterrupted" });
98
+ this.interruptTimeout = null;
99
+ }, resetDuration);
100
+ }
101
+ async setDevice(config) {
102
+ if (!("setSinkId" in HTMLAudioElement.prototype)) {
103
+ throw new Error("setSinkId is not supported in this browser");
104
+ }
105
+ // Extract outputDeviceId from config
106
+ const outputDeviceId = config?.outputDeviceId;
107
+ // Note: sampleRate and format cannot be changed on an existing output
108
+ // (would require recreating the AudioContext).
109
+ // These options are only used during initial MediaDeviceOutput.create()
110
+ // If deviceId is undefined, use empty string which resets to default device
111
+ await this.audioElement.setSinkId(outputDeviceId || "");
112
+ }
113
+ async close() {
114
+ // Clear any pending interrupt timeout
115
+ if (this.interruptTimeout) {
116
+ clearTimeout(this.interruptTimeout);
117
+ this.interruptTimeout = null;
118
+ }
119
+ // Remove audio element from DOM
120
+ if (this.audioElement.parentNode) {
121
+ this.audioElement.parentNode.removeChild(this.audioElement);
122
+ }
123
+ this.audioElement.pause();
124
+ await this.context.close();
125
+ }
126
+ }
127
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AA8B5E,MAAM,OAAO,iBAAiB;IA6ET;IACA;IACA;IACA;IACA;IA9EZ,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EACzB,UAAU,EACV,MAAM,EACN,cAAc,EACd,YAAY,GAGM;QAClB,IAAI,OAAO,GAAwB,IAAI,CAAC;QACxC,IAAI,YAAY,GAA4B,IAAI,CAAC;QACjD,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;YAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,EA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AAC;QAED,qCAAqC;QACrC,MAAM,cAAc,GAAG,MAAM,EAAE,cAAc,CAAC;QAE9C,sEAAsE;QACtE,+CAA+C;QAC/C,wEAAwE;QAExE,4EAA4E;QAC5E,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,sCAAsC;QACtC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACpC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC/B,CAAC;QAED,gCAAgC;QAChC,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;YACjC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF"}
@@ -2,3 +2,4 @@ import type { SessionConfig } from "./BaseConnection";
2
2
  import type { InitiationClientDataEvent } from "./events";
3
3
  export declare const CONVERSATION_INITIATION_CLIENT_DATA_TYPE = "conversation_initiation_client_data";
4
4
  export declare function constructOverrides(config: SessionConfig): InitiationClientDataEvent;
5
+ //# sourceMappingURL=overrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../src/utils/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAG1D,eAAO,MAAM,wCAAwC,wCACd,CAAC;AAExC,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,GACpB,yBAAyB,CA0C3B"}
@@ -0,0 +1,40 @@
1
+ import { sourceInfo } from "../sourceInfo";
2
+ export const CONVERSATION_INITIATION_CLIENT_DATA_TYPE = "conversation_initiation_client_data";
3
+ export function constructOverrides(config) {
4
+ const overridesEvent = {
5
+ type: CONVERSATION_INITIATION_CLIENT_DATA_TYPE,
6
+ };
7
+ if (config.overrides) {
8
+ overridesEvent.conversation_config_override = {
9
+ agent: {
10
+ prompt: config.overrides.agent?.prompt,
11
+ first_message: config.overrides.agent?.firstMessage,
12
+ language: config.overrides.agent?.language,
13
+ },
14
+ tts: {
15
+ voice_id: config.overrides.tts?.voiceId,
16
+ speed: config.overrides.tts?.speed,
17
+ stability: config.overrides.tts?.stability,
18
+ similarity_boost: config.overrides.tts?.similarityBoost,
19
+ },
20
+ conversation: {
21
+ text_only: config.overrides.conversation?.textOnly,
22
+ },
23
+ };
24
+ }
25
+ if (config.customLlmExtraBody) {
26
+ overridesEvent.custom_llm_extra_body = config.customLlmExtraBody;
27
+ }
28
+ if (config.dynamicVariables) {
29
+ overridesEvent.dynamic_variables = config.dynamicVariables;
30
+ }
31
+ if (config.userId) {
32
+ overridesEvent.user_id = config.userId;
33
+ }
34
+ overridesEvent.source_info = {
35
+ source: sourceInfo.name,
36
+ version: sourceInfo.version,
37
+ };
38
+ return overridesEvent;
39
+ }
40
+ //# sourceMappingURL=overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../src/utils/overrides.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,MAAM,wCAAwC,GACnD,qCAAqC,CAAC;AAExC,MAAM,UAAU,kBAAkB,CAChC,MAAqB;IAErB,MAAM,cAAc,GAA8B;QAChD,IAAI,EAAE,wCAAwC;KAC/C,CAAC;IAEF,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,cAAc,CAAC,4BAA4B,GAAG;YAC5C,KAAK,EAAE;gBACL,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM;gBACtC,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,YAAY;gBACnD,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ;aAC3C;YACD,GAAG,EAAE;gBACH,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO;gBACvC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK;gBAClC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS;gBAC1C,gBAAgB,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,eAAe;aACxD;YACD,YAAY,EAAE;gBACZ,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,QAAQ;aACnD;SACF,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC9B,cAAc,CAAC,qBAAqB,GAAG,MAAM,CAAC,kBAAkB,CAAC;IACnE,CAAC;IAED,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC5B,cAAc,CAAC,iBAAiB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,cAAc,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,CAAC;IAED,cAAc,CAAC,WAAW,GAAG;QAC3B,MAAM,EAAE,UAAU,CAAC,IAAI;QACvB,OAAO,EAAE,UAAU,CAAC,OAAO;KAC5B,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -6,3 +6,4 @@ type Feedback = RatingFeedback;
6
6
  export declare function postOverallFeedback(conversationId: string, like: boolean, origin?: string): Promise<Response>;
7
7
  export declare function postOverallFeedback(conversationId: string, feedback: Feedback, origin?: string): Promise<Response>;
8
8
  export {};
9
+ //# sourceMappingURL=postOverallFeedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postOverallFeedback.d.ts","sourceRoot":"","sources":["../../src/utils/postOverallFeedback.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,QAAQ,GAAG,cAAc,CAAC;AAE/B,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,CAAC,CAAC;AACrB,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ const HTTPS_API_ORIGIN = "https://api.elevenlabs.io";
2
+ export function postOverallFeedback(conversationId, likeOrFeedback, origin = HTTPS_API_ORIGIN) {
3
+ const body = {};
4
+ if (typeof likeOrFeedback === "boolean") {
5
+ body.feedback = likeOrFeedback ? "like" : "dislike";
6
+ }
7
+ else {
8
+ body.rating = likeOrFeedback.rating;
9
+ body.comment = likeOrFeedback.comment;
10
+ }
11
+ return fetch(`${origin}/v1/convai/conversations/${conversationId}/feedback`, {
12
+ method: "POST",
13
+ body: JSON.stringify(body),
14
+ headers: {
15
+ "Content-Type": "application/json",
16
+ },
17
+ });
18
+ }
19
+ //# sourceMappingURL=postOverallFeedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postOverallFeedback.js","sourceRoot":"","sources":["../../src/utils/postOverallFeedback.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAmBrD,MAAM,UAAU,mBAAmB,CACjC,cAAsB,EACtB,cAAkC,EAClC,SAAiB,gBAAgB;IAEjC,MAAM,IAAI,GAIN,EAAE,CAAC;IAEP,IAAI,OAAO,cAAc,KAAK,SAAS,EAAE,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;IACxC,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,MAAM,4BAA4B,cAAc,WAAW,EAAE;QAC3E,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAC1B,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare const loadRawAudioProcessor: (worklet: AudioWorklet, path?: string) => Promise<void>;
2
+ //# sourceMappingURL=rawAudioProcessor.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rawAudioProcessor.generated.d.ts","sourceRoot":"","sources":["../../src/utils/rawAudioProcessor.generated.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,yDAgIjC,CAAC"}
@@ -1,4 +1,8 @@
1
- /*
1
+ // AUTO-GENERATED BY packages/client/scripts/generateWorklets.js
2
+ import { createWorkletModuleLoader } from "./createWorkletModuleLoader";
3
+ export const loadRawAudioProcessor = createWorkletModuleLoader("rawAudioProcessor",
4
+ // language=JavaScript
5
+ `/*
2
6
  * ulaw encoding logic taken from the wavefile library
3
7
  * https://github.com/rochars/wavefile/blob/master/lib/codecs/mulaw.js
4
8
  * USED BY @elevenlabs/client
@@ -122,3 +126,5 @@ class RawAudioProcessor extends AudioWorkletProcessor {
122
126
  }
123
127
  }
124
128
  registerProcessor("rawAudioProcessor", RawAudioProcessor);
129
+ `);
130
+ //# sourceMappingURL=rawAudioProcessor.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rawAudioProcessor.generated.js","sourceRoot":"","sources":["../../src/utils/rawAudioProcessor.generated.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAC5D,mBAAmB;AACnB,sBAAsB;AACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4HD,CACA,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare const loadScribeAudioProcessor: (worklet: AudioWorklet, path?: string) => Promise<void>;
2
+ //# sourceMappingURL=scribeAudioProcessor.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scribeAudioProcessor.generated.d.ts","sourceRoot":"","sources":["../../src/utils/scribeAudioProcessor.generated.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,yDA8GpC,CAAC"}
@@ -1,4 +1,8 @@
1
- /*
1
+ // AUTO-GENERATED BY packages/client/scripts/generateWorklets.js
2
+ import { createWorkletModuleLoader } from "./createWorkletModuleLoader";
3
+ export const loadScribeAudioProcessor = createWorkletModuleLoader("scribeAudioProcessor",
4
+ // language=JavaScript
5
+ `/*
2
6
  * Scribe Audio Processor for converting microphone audio to PCM16 format
3
7
  * Supports resampling for browsers like Firefox that don't support
4
8
  * AudioContext sample rate constraints.
@@ -104,3 +108,5 @@ class ScribeAudioProcessor extends AudioWorkletProcessor {
104
108
 
105
109
  registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
106
110
 
111
+ `);
112
+ //# sourceMappingURL=scribeAudioProcessor.generated.js.map