Convert WAV to MP3

In C-Sharp,

Call the ConvertWavToMp3 function like this:

ConvertWavToMp3(wavFile, outputFile);

You'll also need to define the ConvertWavToMp3 function.

ConvertWavToMp3 function

Here is the ConvertWavToMp3 function.

public static void ConvertWavToMp3(string wavFilePath, string mp3FilePath, int bitrateKbps = 192)
{
	using var reader = new AudioFileReader(wavFilePath);
	using var writer = new LameMP3FileWriter(mp3FilePath, reader.WaveFormat, bitrateKbps);

	reader.CopyTo(writer);
}

You'll need to import Naudio, and Naudio.Lame and Naudio.Wave.

See also