feat: integrate Chinese speech understanding and capability routing
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
class SpeechCaptureProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.frameSize = 2048;
|
||||
this.frame = new Float32Array(this.frameSize);
|
||||
this.offset = 0;
|
||||
}
|
||||
|
||||
process(inputs) {
|
||||
const input = inputs[0]?.[0];
|
||||
if (!input) return true;
|
||||
let inputOffset = 0;
|
||||
while (inputOffset < input.length) {
|
||||
const available = Math.min(this.frameSize - this.offset, input.length - inputOffset);
|
||||
this.frame.set(input.subarray(inputOffset, inputOffset + available), this.offset);
|
||||
this.offset += available;
|
||||
inputOffset += available;
|
||||
if (this.offset === this.frameSize) {
|
||||
const ready = this.frame;
|
||||
this.port.postMessage(ready, [ready.buffer]);
|
||||
this.frame = new Float32Array(this.frameSize);
|
||||
this.offset = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor("speech-capture-processor", SpeechCaptureProcessor);
|
||||
Reference in New Issue
Block a user