MCPcopy Create free account
hub / github.com/KoljaB/RealtimeVoiceChat / process

Method process

code/static/ttsPlaybackProcessor.js:28–65  ·  view source on GitHub ↗
(inputs, outputs)

Source from the content-addressed store, hash-verified

26 }
27
28 process(inputs, outputs) {
29 const outputChannel = outputs[0][0];
30
31 if (this.samplesRemaining === 0) {
32 outputChannel.fill(0);
33 if (this.isPlaying) {
34 this.isPlaying = false;
35 this.port.postMessage({ type: 'ttsPlaybackStopped' });
36 }
37 return true;
38 }
39
40 if (!this.isPlaying) {
41 this.isPlaying = true;
42 this.port.postMessage({ type: 'ttsPlaybackStarted' });
43 }
44
45 let outIdx = 0;
46 while (outIdx < outputChannel.length && this.bufferQueue.length > 0) {
47 const currentBuffer = this.bufferQueue[0];
48 const sampleValue = currentBuffer[this.readOffset] / 32768;
49 outputChannel[outIdx++] = sampleValue;
50
51 this.readOffset++;
52 this.samplesRemaining--;
53
54 if (this.readOffset >= currentBuffer.length) {
55 this.bufferQueue.shift();
56 this.readOffset = 0;
57 }
58 }
59
60 while (outIdx < outputChannel.length) {
61 outputChannel[outIdx++] = 0;
62 }
63
64 return true;
65 }
66}
67
68registerProcessor('tts-playback-processor', TTSPlaybackProcessor);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected