@vapi-ai/web 1.0.53 → 1.0.55

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
@@ -4,7 +4,6 @@ export declare class ContinuousPlayer extends EventEmitter {
4
4
  private mediaSource;
5
5
  private sourceBuffer;
6
6
  private audio;
7
- private nextTimestamp;
8
7
  private audioQueue;
9
8
  constructor();
10
9
  start(): void;
package/dist/player.js CHANGED
@@ -10,7 +10,6 @@ class ContinuousPlayer extends events_1.default {
10
10
  constructor() {
11
11
  super();
12
12
  this.sourceBuffer = null;
13
- this.nextTimestamp = 0;
14
13
  this.mediaSource = new MediaSource();
15
14
  this.audio = document.createElement("audio");
16
15
  this.audio.src = URL.createObjectURL(this.mediaSource);
@@ -21,9 +20,6 @@ class ContinuousPlayer extends events_1.default {
21
20
  this.mediaSource.addEventListener("sourceopen", () => {
22
21
  this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/webm; codecs="opus"');
23
22
  this.sourceBuffer.addEventListener("updateend", () => {
24
- if (this.sourceBuffer && this.sourceBuffer.buffered.length > 0) {
25
- this.sourceBuffer.timestampOffset = this.sourceBuffer.buffered.end(0);
26
- }
27
23
  this.audioQueue.resume();
28
24
  });
29
25
  });
@@ -36,11 +32,14 @@ class ContinuousPlayer extends events_1.default {
36
32
  }
37
33
  appendNextChunk(chunk, callback) {
38
34
  if (this.sourceBuffer && !this.sourceBuffer.updating) {
35
+ if (this.sourceBuffer.buffered.length > 0) {
36
+ this.sourceBuffer.timestampOffset = this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length - 1);
37
+ }
39
38
  console.log("appending", this.sourceBuffer.timestampOffset);
40
39
  this.sourceBuffer.appendBuffer(chunk);
41
40
  this.audioQueue.pause();
42
41
  }
43
- callback(null);
42
+ callback();
44
43
  }
45
44
  clear() {
46
45
  if (this.sourceBuffer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/player.ts CHANGED
@@ -6,7 +6,6 @@ export class ContinuousPlayer extends EventEmitter {
6
6
  private mediaSource: MediaSource;
7
7
  private sourceBuffer: SourceBuffer | null = null;
8
8
  private audio: HTMLAudioElement;
9
- private nextTimestamp: number = 0;
10
9
  private audioQueue: QueueObject<ArrayBuffer>;
11
10
 
12
11
  constructor() {
@@ -27,9 +26,6 @@ export class ContinuousPlayer extends EventEmitter {
27
26
  );
28
27
 
29
28
  this.sourceBuffer.addEventListener("updateend", () => {
30
- if (this.sourceBuffer && this.sourceBuffer.buffered.length > 0) {
31
- this.sourceBuffer.timestampOffset = this.sourceBuffer.buffered.end(0);
32
- }
33
29
  this.audioQueue.resume();
34
30
  });
35
31
  });
@@ -48,11 +44,16 @@ export class ContinuousPlayer extends EventEmitter {
48
44
  callback: async.ErrorCallback<Error>
49
45
  ): void {
50
46
  if (this.sourceBuffer && !this.sourceBuffer.updating) {
47
+ if (this.sourceBuffer.buffered.length > 0) {
48
+ this.sourceBuffer.timestampOffset = this.sourceBuffer.buffered.end(
49
+ this.sourceBuffer.buffered.length - 1
50
+ );
51
+ }
51
52
  console.log("appending", this.sourceBuffer.timestampOffset);
52
53
  this.sourceBuffer.appendBuffer(chunk);
53
54
  this.audioQueue.pause();
54
55
  }
55
- callback(null);
56
+ callback();
56
57
  }
57
58
 
58
59
  clear(): void {