Search code examples
c#audionaudio

Converting .vox audio files to .wav or .mp3 with NAudio


I am trying to convert .vox to .mp3 or .wav with NAudio with the code below:-

var bytes = GetBytes(new FileInfo(@"D:\path\to\vox-file.vox"));

using (var writer = new WaveFileWriter(@"D:\path\to\wav-file.wav", new WaveFormat(8000, 8, 2)))
{
    writer.Write(bytes, 0, bytes.Length);
}

However the converted .wav file I am getting has very distorted audio and its not listenable. Am I missing some configuration with NAudio?


Solution

  • I was able to convert .vox files to .wav with the following:-

    var bytes = GetBytes(new FileInfo(@"path-to.vox"));
    
    using (var writer = new WaveFileWriter(@"path-to.wav", Mp3WaveFormat.CreateMuLawFormat(8000, 1)))
    {
        writer.Write(bytes, 0, bytes.Length);
    }
    

    The important bit here is this part: Mp3WaveFormat.CreateMuLawFormat(8000, 1), this is basically some kind of format/configuration for the .wav file which you want to be created and these values may vary depending upon your .vox files