function convertMP3toWAV(req, sendToSpeechRecognition){
    var droneName = req.params.dronename;
    var mp3File = req.file.path;
    var body= req.body;
    var decoder = new lame.Decoder();

    var mp3FileStream = fs.createReadStream(mp3File);
    var wavFileStream = fs.createWriteStream(mp3File.replace(".mp3",".wav"));

    decoder.on('format', function(format){
        var writer = new wav.Writer(format);
        decoder.pipe(writer).pipe(wavFileStream);
    });

    mp3FileStream.pipe(decoder);

    decoder.on('finish', function(){
        logger.info("Converted file");
        sendToSpeechRecognition(req, '.mp3');
});

    function onFormat(format){
        var writer = new wav.Writer(format);
        decoder.pipe(writer).pipe(wavFileStream);
    }

}
/**
 * Convert mp3 file to wav before callback
 * @param mp3File {String} Path to mp3file to convert
 * @param body {Object} Body of original req
 * @param sendToSpeechRecognition {Function} dat function
 */
Convert mp3 file to wav before callback
@param mp3File {String} Path to mp3file to convert
@param body {Object} Body of original req
@param sendToSpeechRecognition {Function} dat function
Convert mp3 file to wav before callback @param mp3File { String } Path to mp3file to convert @param body { Object } Body of original req @param sendToSpeechRecognition { Function } dat function
function convertMP3toWAV(req, sendToSpeechRecognition){
    var droneName = req.params.dronename;
    var mp3File = req.file.path;
    var body= req.body;
    var decoder = new lame.Decoder();
    var mp3FileStream = fs.createReadStream(mp3File);
    var wavFileStream = fs.createWriteStream(mp3File.replace(".mp3",".wav"));
    decoder.on('format', function(format){
        var writer = new wav.Writer(format);
        decoder.pipe(writer).pipe(wavFileStream);
    });
    mp3FileStream.pipe(decoder);
    decoder.on('finish', function(){
        logger.info("Converted file");
        sendToSpeechRecognition(req, '.mp3');
});
    function onFormat(format){
        var writer = new wav.Writer(format);
        decoder.pipe(writer).pipe(wavFileStream);
    }
}
function convertMP3toWAV ( req , sendToSpeechRecognition ) { var droneName = req . params . dronename ; var mp3File = req . file . path ; var body = req . body ; var decoder = new lame . Decoder ( ) ; var mp3FileStream = fs . createReadStream ( mp3File ) ; var wavFileStream = fs . createWriteStream ( mp3File . replace ( ".mp3" , ".wav" ) ) ; decoder . on ( 'format' , function ( format ) { var writer = new wav . Writer ( format ) ; decoder . pipe ( writer ) . pipe ( wavFileStream ) ; } ) ; mp3FileStream . pipe ( decoder ) ; decoder . on ( 'finish' , function ( ) { logger . info ( "Converted file" ) ; sendToSpeechRecognition ( req , '.mp3' ) ; } ) ; function onFormat ( format ) { var writer = new wav . Writer ( format ) ; decoder . pipe ( writer ) . pipe ( wavFileStream ) ; } }
Convert mp3 file to wav before callback
 @param mp3File {String} Path to mp3file to convert
 @param body {Object} Body of original req
 @param sendToSpeechRecognition {Function} dat function
Convert mp3 file to wav before callback @param mp3File { String } Path to mp3file to convert @param body { Object } Body of original req @param sendToSpeechRecognition { Function } dat function