Open behrendCoreysGIT opened 5 years ago
I ran into the same issue. Recorded .wav file was ~twice as long, slowed down, way deeper voice.
After a bunch of random tinkering, what fixed it for me was putting the FileWriter's
sampleRate to double the mic's
.
For example like this:
var micInstance = mic({
rate: '16000',
channels: '1',
debug: true
});
var micInputStream = micInstance.getAudioStream();
var outputFileStream = new FileWriter('./test.wav', {
sampleRate: 32000, // double the rate above
channels: 1
});
When I run the "Example usage with mic:" code for saving the stream as a .wav the resulting file is drastically slowed down. So a 5-second recording is a minimum of 10s. Note that if I speed this audio up in a video editing software it sounds perfect. (Windows 10 / SoX 14.4.1)
//The code var FileWriter = require('wav').FileWriter; var mic = require('mic');
var micInstance = mic({ rate: '16000', channels: '1', debug: true });
var micInputStream = micInstance.getAudioStream();
var outputFileStream = new FileWriter('./test.wav', { sampleRate: 16000, channels: 1 });
micInputStream.pipe(outputFileStream);
micInstance.start();
setTimeout(function() { micInstance.stop(); }, 5000);