-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
I am having very hard times to get this working.
I tried to convert the pcmdata do Float32Array but I always get audio with cracks. It is possible to hear and recognize voice but it's not clear and cracks a lot, unusable.
Can you please help me with this ?
Here is my code:
let audio = new Int16Array(pcmData.length / Int16Array.BYTES_PER_ELEMENT);
let length = audio.length;
for (let i = 0; i < length; ++i) {
audio[i] = pcmData.readInt16LE(i * Int16Array.BYTES_PER_ELEMENT);
}
let right = new Float32Array(audio.length);
let channelCounter = 0;
for (let i=0; i < audio.length; i++) {
let normalizedRight = audio[i] / 32768;
right[channelCounter] = normalizedRight;
channelCounter++;
}
let source = this.audioContext.createBufferSource();
let audioBuffer = this.audioContext.createBuffer(1, right.length, 48000);
audioBuffer.getChannelData(0).set(right);
source.buffer = audioBuffer;
source.connect(this.audioContext.destination);
if(this.startTime == 0) this.startTime = this.audioContext.currentTime + (audioBuffer.length / audioBuffer.sampleRate)/2;
source.start(this.startTime);
this.startTime += audioBuffer.length / audioBuffer.sampleRate;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels