세션 평가와 교수자 분석 보강
This commit is contained in:
parent
5c4ac04e06
commit
fe2796f05a
51 changed files with 4928 additions and 240 deletions
|
|
@ -4,6 +4,13 @@ class VoiceCaptureProcessor extends AudioWorkletProcessor {
|
|||
this.pending = [];
|
||||
this.pendingLength = 0;
|
||||
this.flushSamples = Math.max(1024, Math.floor(sampleRate * 0.25));
|
||||
this.totalSamples = 0;
|
||||
this.voiceSamples = 0;
|
||||
this.silentSamples = 0;
|
||||
this.trailingSilentSamples = 0;
|
||||
this.sumSquares = 0;
|
||||
this.peak = 0;
|
||||
this.voiceThreshold = 0.018;
|
||||
this.port.onmessage = (event) => {
|
||||
if (event.data && event.data.type === "flush") {
|
||||
this.flush();
|
||||
|
|
@ -19,6 +26,17 @@ class VoiceCaptureProcessor extends AudioWorkletProcessor {
|
|||
const pcm = new Int16Array(channel.length);
|
||||
for (let i = 0; i < channel.length; i += 1) {
|
||||
const sample = Math.max(-1, Math.min(1, channel[i]));
|
||||
const abs = Math.abs(sample);
|
||||
this.totalSamples += 1;
|
||||
this.sumSquares += sample * sample;
|
||||
if (abs > this.peak) this.peak = abs;
|
||||
if (abs >= this.voiceThreshold) {
|
||||
this.voiceSamples += 1;
|
||||
this.trailingSilentSamples = 0;
|
||||
} else {
|
||||
this.silentSamples += 1;
|
||||
this.trailingSilentSamples += 1;
|
||||
}
|
||||
pcm[i] = sample < 0 ? sample * 0x8000 : sample * 0x7fff;
|
||||
}
|
||||
|
||||
|
|
@ -46,11 +64,28 @@ class VoiceCaptureProcessor extends AudioWorkletProcessor {
|
|||
sampleRate,
|
||||
channels: 1,
|
||||
sampleWidth: 2,
|
||||
metrics: this.metrics(),
|
||||
pcm: merged.buffer,
|
||||
},
|
||||
[merged.buffer],
|
||||
);
|
||||
}
|
||||
|
||||
metrics() {
|
||||
const durationMs = (this.totalSamples / sampleRate) * 1000;
|
||||
const voiceMs = (this.voiceSamples / sampleRate) * 1000;
|
||||
const silenceMs = (this.silentSamples / sampleRate) * 1000;
|
||||
const trailingSilenceMs = (this.trailingSilentSamples / sampleRate) * 1000;
|
||||
const rms = this.totalSamples > 0 ? Math.sqrt(this.sumSquares / this.totalSamples) : 0;
|
||||
return {
|
||||
durationMs,
|
||||
voiceMs,
|
||||
silenceMs,
|
||||
trailingSilenceMs,
|
||||
rms,
|
||||
peak: this.peak,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor("voice-capture-processor", VoiceCaptureProcessor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue