@vapi-ai/web 1.0.65 → 1.0.67

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,6 +22,7 @@ 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
27
  console.log("RESUMING");
27
28
  });
@@ -40,6 +41,22 @@ class ContinuousPlayer extends events_1.default {
40
41
  }
41
42
  callback();
42
43
  }
44
+ checkForGaps() {
45
+ if (this.sourceBuffer) {
46
+ for (let i = 0; i < this.sourceBuffer.buffered.length; i++) {
47
+ // Start and end times of the buffered range
48
+ let start = this.sourceBuffer.buffered.start(i);
49
+ let end = this.sourceBuffer.buffered.end(i);
50
+ // Check if there is a gap between the end of this range and the start of the next one
51
+ if (i < this.sourceBuffer.buffered.length - 1) {
52
+ let nextStart = this.sourceBuffer.buffered.start(i + 1);
53
+ if (end < nextStart) {
54
+ console.log(`Gap detected between ${end} and ${nextStart}`);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
43
60
  clear() {
44
61
  if (this.sourceBuffer) {
45
62
  if (this.sourceBuffer.updating) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.65",
3
+ "version": "1.0.67",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/player.ts CHANGED
@@ -28,6 +28,7 @@ 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
33
  console.log("RESUMING");
33
34
  });
@@ -53,6 +54,24 @@ export class ContinuousPlayer extends EventEmitter {
53
54
  callback();
54
55
  }
55
56
 
57
+ private checkForGaps(): void {
58
+ if (this.sourceBuffer) {
59
+ for (let i = 0; i < this.sourceBuffer.buffered.length; i++) {
60
+ // Start and end times of the buffered range
61
+ let start = this.sourceBuffer.buffered.start(i);
62
+ let end = this.sourceBuffer.buffered.end(i);
63
+
64
+ // Check if there is a gap between the end of this range and the start of the next one
65
+ if (i < this.sourceBuffer.buffered.length - 1) {
66
+ let nextStart = this.sourceBuffer.buffered.start(i + 1);
67
+ if (end < nextStart) {
68
+ console.log(`Gap detected between ${end} and ${nextStart}`);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+
56
75
  clear(): void {
57
76
  if (this.sourceBuffer) {
58
77
  if (this.sourceBuffer.updating) {