@vapi-ai/web 1.1.7 → 1.3.0

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 DELETED
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- import EventEmitter from "events";
3
- export declare class ContinuousPlayer extends EventEmitter {
4
- private atomic;
5
- private audio;
6
- constructor();
7
- start(): void;
8
- playChunk(audioData: ArrayBuffer): void;
9
- clear(): void;
10
- }
package/dist/player.js DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ContinuousPlayer = void 0;
7
- const AtomicMediaSource_1 = __importDefault(require("./AtomicMediaSource"));
8
- const events_1 = __importDefault(require("events"));
9
- class ContinuousPlayer extends events_1.default {
10
- constructor() {
11
- super();
12
- this.audio = document.createElement("audio");
13
- this.audio.addEventListener("playing", () => this.emit("speech-start"));
14
- this.audio.addEventListener("play", () => this.emit("speech-start"));
15
- this.audio.addEventListener("canplay", () => {
16
- this.audio.play();
17
- });
18
- this.audio.addEventListener("waiting", () => this.emit("speech-end"));
19
- this.atomic = new AtomicMediaSource_1.default();
20
- this.audio.src = URL.createObjectURL(this.atomic.mediaSource);
21
- document.body.appendChild(this.audio);
22
- }
23
- start() {
24
- this.audio.play();
25
- }
26
- playChunk(audioData) {
27
- var _a;
28
- (_a = this.atomic.sourceBuffer) === null || _a === void 0 ? void 0 : _a.addEventListener("updateend", () => {
29
- this.audio.play().catch((error) => console.error("Play error:", error));
30
- }, { once: true });
31
- this.atomic.appendBuffer(audioData);
32
- }
33
- clear() {
34
- this.audio.pause();
35
- this.atomic.clearBuffer();
36
- }
37
- }
38
- exports.ContinuousPlayer = ContinuousPlayer;