@vapi-ai/web 1.0.10 → 1.0.12
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 +1 -0
- package/dist/player.js +7 -3
- package/dist/vapi.js +1 -0
- package/package.json +1 -1
- package/player.ts +7 -4
- package/vapi.ts +1 -0
package/dist/player.d.ts
CHANGED
package/dist/player.js
CHANGED
|
@@ -18,14 +18,18 @@ class ContinuousPlayer extends events_1.default {
|
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
20
|
this.sourceBuffer = null;
|
|
21
|
+
this.audio = null;
|
|
21
22
|
this.mediaSource = new MediaSource();
|
|
22
|
-
this.audio = new Audio();
|
|
23
|
-
this.audio.src = URL.createObjectURL(this.mediaSource);
|
|
24
|
-
this.audio.play();
|
|
25
23
|
this.mediaSource.onsourceopen = () => {
|
|
26
24
|
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/webm; codecs="opus"');
|
|
25
|
+
this.audio = new Audio();
|
|
26
|
+
this.audio.src = URL.createObjectURL(this.mediaSource);
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
start() {
|
|
30
|
+
var _a;
|
|
31
|
+
(_a = this.audio) === null || _a === void 0 ? void 0 : _a.play();
|
|
32
|
+
}
|
|
29
33
|
playChunk(audioData) {
|
|
30
34
|
if (!this.sourceBuffer)
|
|
31
35
|
return;
|
package/dist/vapi.js
CHANGED
package/package.json
CHANGED
package/player.ts
CHANGED
|
@@ -3,22 +3,25 @@ import EventEmitter from "events";
|
|
|
3
3
|
export class ContinuousPlayer extends EventEmitter {
|
|
4
4
|
private mediaSource: MediaSource;
|
|
5
5
|
private sourceBuffer: SourceBuffer | null = null;
|
|
6
|
-
private audio: HTMLAudioElement;
|
|
6
|
+
private audio: HTMLAudioElement | null = null;
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
10
|
this.mediaSource = new MediaSource();
|
|
11
|
-
this.audio = new Audio();
|
|
12
|
-
this.audio.src = URL.createObjectURL(this.mediaSource);
|
|
13
|
-
this.audio.play();
|
|
14
11
|
|
|
15
12
|
this.mediaSource.onsourceopen = () => {
|
|
16
13
|
this.sourceBuffer = this.mediaSource.addSourceBuffer(
|
|
17
14
|
'audio/webm; codecs="opus"'
|
|
18
15
|
);
|
|
16
|
+
this.audio = new Audio();
|
|
17
|
+
this.audio.src = URL.createObjectURL(this.mediaSource);
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
20
|
|
|
21
|
+
start() {
|
|
22
|
+
this.audio?.play();
|
|
23
|
+
}
|
|
24
|
+
|
|
22
25
|
playChunk(audioData: ArrayBuffer) {
|
|
23
26
|
if (!this.sourceBuffer) return;
|
|
24
27
|
console.log(this.mediaSource.readyState, this.sourceBuffer.updating);
|