I have audio data in format of data-uri, then I converted this data-uri into a buffer now I need this buffer data in new samplerate, currently audio data is in 44.1khz and I need data in 16khz, and If I recorded the audio using RecordRTC API and if I record audio in low sample rate then I got distorted audio voice, So I am not getting how to resample my audio buffer,
If any of you any idea regarding this then please help me out.
Thanks in advance :)
if you are using chrome browser you can directly specify sample rate in AudioContext .
1.You can directly record sound via microphone .
var context = new AudioContext({
sampleRate: 16000,
});
2.If you already has a file or ArrayBuffer .Then you can resample it using the same audio context
const fileReader = new FileReader();
fileReader.readAsArrayBuffer(target.files[0]);
fileReader.onload = (e) => {
//e.target.result is an ArrayBuffer
context.decodeAudioData(e.target.result, async function(buffer) {
console.log(buffer)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With