@vapi-ai/web 1.0.17 → 1.0.18

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/player.js CHANGED
@@ -15,6 +15,7 @@ class ContinuousPlayer extends events_1.default {
15
15
  this.mediaSource.addEventListener("sourceopen", () => {
16
16
  this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/webm; codecs="opus"');
17
17
  this.audio = document.createElement("audio");
18
+ document.body.appendChild(this.audio);
18
19
  this.audio.src = URL.createObjectURL(this.mediaSource);
19
20
  this.sourceBuffer.addEventListener("updateend", () => {
20
21
  this.appendNextChunk();
@@ -23,6 +24,7 @@ class ContinuousPlayer extends events_1.default {
23
24
  }
24
25
  start() {
25
26
  var _a;
27
+ console.log("playing", !!this.audio);
26
28
  (_a = this.audio) === null || _a === void 0 ? void 0 : _a.play();
27
29
  }
28
30
  playChunk(audioData) {
@@ -30,9 +32,11 @@ class ContinuousPlayer extends events_1.default {
30
32
  this.appendNextChunk();
31
33
  }
32
34
  appendNextChunk() {
35
+ console.log("appending");
33
36
  if (this.sourceBuffer &&
34
37
  !this.sourceBuffer.updating &&
35
38
  this.audioQueue.length > 0) {
39
+ console.log("appended");
36
40
  const chunk = this.audioQueue.shift();
37
41
  if (chunk) {
38
42
  this.sourceBuffer.appendBuffer(chunk);
package/dist/vapi.d.ts CHANGED
@@ -6,7 +6,6 @@ export default class Vapi extends EventEmitter {
6
6
  private ws;
7
7
  private mediaRecorder;
8
8
  private player;
9
- private audioQueue;
10
9
  constructor(apiToken: string);
11
10
  start(agent: CreateAgentDTO | string): void;
12
11
  private startRecording;
package/dist/vapi.js CHANGED
@@ -13,7 +13,6 @@ class Vapi extends events_1.default {
13
13
  this.started = false;
14
14
  this.ws = null;
15
15
  this.mediaRecorder = null;
16
- this.audioQueue = [];
17
16
  client_1.client.setSecurityData(apiToken);
18
17
  this.player = new player_1.ContinuousPlayer();
19
18
  this.player.on("speech-start", () => this.emit("speech-start"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/player.ts CHANGED
@@ -15,6 +15,8 @@ export class ContinuousPlayer extends EventEmitter {
15
15
  'audio/webm; codecs="opus"'
16
16
  );
17
17
  this.audio = document.createElement("audio");
18
+ document.body.appendChild(this.audio);
19
+
18
20
  this.audio.src = URL.createObjectURL(this.mediaSource);
19
21
  this.sourceBuffer.addEventListener("updateend", () => {
20
22
  this.appendNextChunk();
@@ -23,6 +25,8 @@ export class ContinuousPlayer extends EventEmitter {
23
25
  }
24
26
 
25
27
  start() {
28
+ console.log("playing", !!this.audio);
29
+
26
30
  this.audio?.play();
27
31
  }
28
32
 
@@ -33,11 +37,13 @@ export class ContinuousPlayer extends EventEmitter {
33
37
  }
34
38
 
35
39
  private appendNextChunk(): void {
40
+ console.log("appending");
36
41
  if (
37
42
  this.sourceBuffer &&
38
43
  !this.sourceBuffer.updating &&
39
44
  this.audioQueue.length > 0
40
45
  ) {
46
+ console.log("appended");
41
47
  const chunk = this.audioQueue.shift();
42
48
  if (chunk) {
43
49
  this.sourceBuffer.appendBuffer(chunk);
package/vapi.ts CHANGED
@@ -10,7 +10,6 @@ export default class Vapi extends EventEmitter {
10
10
  private ws: WebSocket | null = null;
11
11
  private mediaRecorder: MediaRecorder | null = null;
12
12
  private player: ContinuousPlayer;
13
- private audioQueue: ArrayBuffer[] = [];
14
13
 
15
14
  constructor(apiToken: string) {
16
15
  super();