0

I have a web application that returns a byte [] from a wav file in the browser, however I need to convert these audio files to .mp3, I tried to use the Naudio library for this and I could not.

I try to use this code:

public static byte[] ConvertWavToMp3(byte[] wavFile)
{

        using(var retMs = new MemoryStream())
        using (var ms = new MemoryStream(wavFile))
        using(var rdr = new WaveFileReader(ms))
        using (var wtr = new LameMP3FileWriter(retMs, rdr.WaveFormat, 128))
        {
            rdr.CopyTo(wtr);
            return retMs.ToArray();
        }


    }

It's return an error :

Unsupported encoding format ALaw Parameter name: format

Dan Wilson
  • 3,937
  • 2
  • 17
  • 27
  • Possible duplicate of [LameMP3FileWriter: Unsupported encoding format MuLaw Parameter name: format](https://stackoverflow.com/questions/28888685/lamemp3filewriter-unsupported-encoding-format-mulaw-parameter-name-format) – C-Pound Guru Jun 11 '18 at 18:49
  • Possible duplicate of [change format from wav to mp3 in memory stream in NAudio](https://stackoverflow.com/questions/19058530/change-format-from-wav-to-mp3-in-memory-stream-in-naudio) – Hesam Faridmehr Jun 11 '18 at 18:49

0 Answers0