@vapi-ai/web 1.0.66 → 1.0.69

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.d.ts CHANGED
@@ -9,5 +9,6 @@ export declare class ContinuousPlayer extends EventEmitter {
9
9
  start(): void;
10
10
  playChunk(audioData: ArrayBuffer): void;
11
11
  private appendNextChunk;
12
+ private checkForGaps;
12
13
  clear(): void;
13
14
  }
package/dist/player.js CHANGED
@@ -22,8 +22,8 @@ class ContinuousPlayer extends events_1.default {
22
22
  this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/webm; codecs="opus"');
23
23
  this.sourceBuffer.mode = "sequence";
24
24
  this.sourceBuffer.addEventListener("updateend", () => {
25
+ this.checkForGaps();
25
26
  this.audioQueue.resume();
26
- console.log("RESUMING");
27
27
  });
28
28
  });
29
29
  }
@@ -40,6 +40,25 @@ class ContinuousPlayer extends events_1.default {
40
40
  }
41
41
  callback();
42
42
  }
43
+ checkForGaps() {
44
+ if (this.sourceBuffer && this.sourceBuffer.buffered.length > 0) {
45
+ console.log(this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length - 1));
46
+ }
47
+ if (this.sourceBuffer) {
48
+ for (let i = 0; i < this.sourceBuffer.buffered.length; i++) {
49
+ // Start and end times of the buffered range
50
+ let start = this.sourceBuffer.buffered.start(i);
51
+ let end = this.sourceBuffer.buffered.end(i);
52
+ // Check if there is a gap between the end of this range and the start of the next one
53
+ if (i < this.sourceBuffer.buffered.length - 1) {
54
+ let nextStart = this.sourceBuffer.buffered.start(i + 1);
55
+ if (end < nextStart) {
56
+ console.log(`Gap detected between ${end} and ${nextStart}`);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
43
62
  clear() {
44
63
  if (this.sourceBuffer) {
45
64
  if (this.sourceBuffer.updating) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.66",
3
+ "version": "1.0.69",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/player.ts CHANGED
@@ -28,8 +28,8 @@ export class ContinuousPlayer extends EventEmitter {
28
28
  this.sourceBuffer.mode = "sequence";
29
29
 
30
30
  this.sourceBuffer.addEventListener("updateend", () => {
31
+ this.checkForGaps();
31
32
  this.audioQueue.resume();
32
- console.log("RESUMING");
33
33
  });
34
34
  });
35
35
  }
@@ -53,6 +53,29 @@ export class ContinuousPlayer extends EventEmitter {
53
53
  callback();
54
54
  }
55
55
 
56
+ private checkForGaps(): void {
57
+ if (this.sourceBuffer && this.sourceBuffer.buffered.length > 0) {
58
+ console.log(
59
+ this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length - 1)
60
+ );
61
+ }
62
+ if (this.sourceBuffer) {
63
+ for (let i = 0; i < this.sourceBuffer.buffered.length; i++) {
64
+ // Start and end times of the buffered range
65
+ let start = this.sourceBuffer.buffered.start(i);
66
+ let end = this.sourceBuffer.buffered.end(i);
67
+
68
+ // Check if there is a gap between the end of this range and the start of the next one
69
+ if (i < this.sourceBuffer.buffered.length - 1) {
70
+ let nextStart = this.sourceBuffer.buffered.start(i + 1);
71
+ if (end < nextStart) {
72
+ console.log(`Gap detected between ${end} and ${nextStart}`);
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+
56
79
  clear(): void {
57
80
  if (this.sourceBuffer) {
58
81
  if (this.sourceBuffer.updating) {