Closed foprel closed 3 years ago
Hi @foprel, I am using this piece of code and it works well for me:
navigator.mediaDevices.getUserMedia({ audio: true })
.then(function (stream) {
recorder = RecordRTC(stream, {
type: 'audio',
mimeType: 'audio/webm',
sampleRate: 44100,
recorderType: StereoAudioRecorder,
numberOfAudioChannels: 1,
timeSlice: 4000,
desiredSampRate: 16000,
ondataavailable: function(blob) {
var stream = ss.createStream();
ss(socket).emit('stream-transcribe', stream, {
name: 'stream.wav',
size: blob.size
});
ss.createBlobReadStream(blob).pipe(stream);
}
});
recorder.startRecording();
})
.catch((err) => console.error('getUserMedia', err));
};
Per documentation, to use ondataavailable
you need to include timeSlice
as well.
Thanks for your response. You are right, every seems to work when I include timeSlice
. It properly returns a blob in 'audio/wav' format too.
I should have read the documentation more carefully. Closing this issue now.
I'm trying to generate an 'audio/wav' stream and send it to a python backend. However, when I call ondataavailable, I'm not recieving a blob in 'audio/wav', but a blob with a byte array, which seems to be webm. Is there a way to chop the stream into chunks and receive a blob in wave format every time?
I have tried calling getBlob() while streaming, but this returns the following error:
RecordRTC.js:257 Blob encoder did not finish its job yet.