@vapi-ai/web 1.0.54 → 1.0.56
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.js +1 -10
- package/package.json +1 -1
- package/player.ts +1 -13
package/dist/player.js
CHANGED
|
@@ -6,12 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ContinuousPlayer = void 0;
|
|
7
7
|
const async_1 = __importDefault(require("async"));
|
|
8
8
|
const events_1 = __importDefault(require("events"));
|
|
9
|
-
const calculateChunkDuration = (chunk) => {
|
|
10
|
-
const sampleRate = 48000;
|
|
11
|
-
const bitDepth = 16;
|
|
12
|
-
const duration = chunk.byteLength / ((sampleRate * bitDepth) / 8);
|
|
13
|
-
return duration;
|
|
14
|
-
};
|
|
15
9
|
class ContinuousPlayer extends events_1.default {
|
|
16
10
|
constructor() {
|
|
17
11
|
super();
|
|
@@ -38,13 +32,10 @@ class ContinuousPlayer extends events_1.default {
|
|
|
38
32
|
}
|
|
39
33
|
appendNextChunk(chunk, callback) {
|
|
40
34
|
if (this.sourceBuffer && !this.sourceBuffer.updating) {
|
|
41
|
-
console.log("appending", this.sourceBuffer.timestampOffset);
|
|
42
35
|
this.sourceBuffer.appendBuffer(chunk);
|
|
43
36
|
this.audioQueue.pause();
|
|
44
|
-
const chunkDurationInSeconds = calculateChunkDuration(chunk);
|
|
45
|
-
this.sourceBuffer.timestampOffset += chunkDurationInSeconds;
|
|
46
37
|
}
|
|
47
|
-
callback(
|
|
38
|
+
callback();
|
|
48
39
|
}
|
|
49
40
|
clear() {
|
|
50
41
|
if (this.sourceBuffer) {
|
package/package.json
CHANGED
package/player.ts
CHANGED
|
@@ -2,14 +2,6 @@ import async, { QueueObject } from "async";
|
|
|
2
2
|
|
|
3
3
|
import EventEmitter from "events";
|
|
4
4
|
|
|
5
|
-
const calculateChunkDuration = (chunk: ArrayBuffer): number => {
|
|
6
|
-
const sampleRate = 48000;
|
|
7
|
-
const bitDepth = 16;
|
|
8
|
-
const duration = chunk.byteLength / ((sampleRate * bitDepth) / 8);
|
|
9
|
-
|
|
10
|
-
return duration;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
5
|
export class ContinuousPlayer extends EventEmitter {
|
|
14
6
|
private mediaSource: MediaSource;
|
|
15
7
|
private sourceBuffer: SourceBuffer | null = null;
|
|
@@ -52,14 +44,10 @@ export class ContinuousPlayer extends EventEmitter {
|
|
|
52
44
|
callback: async.ErrorCallback<Error>
|
|
53
45
|
): void {
|
|
54
46
|
if (this.sourceBuffer && !this.sourceBuffer.updating) {
|
|
55
|
-
console.log("appending", this.sourceBuffer.timestampOffset);
|
|
56
47
|
this.sourceBuffer.appendBuffer(chunk);
|
|
57
48
|
this.audioQueue.pause();
|
|
58
|
-
|
|
59
|
-
const chunkDurationInSeconds = calculateChunkDuration(chunk);
|
|
60
|
-
this.sourceBuffer.timestampOffset += chunkDurationInSeconds;
|
|
61
49
|
}
|
|
62
|
-
callback(
|
|
50
|
+
callback();
|
|
63
51
|
}
|
|
64
52
|
|
|
65
53
|
clear(): void {
|