I'm new to C# and having a ball learning. I've built a text to speech console app for myself that i'm really happy with.
Because I'm so green, but getting a massive buzz from learning, I can't go past the code in this post by wjdavis5 without learning how to use it.
" Install-Package NAudio.Lame Code Snip: Mine obviously returns a byte[] - I have a separate save to disk method b/c I think it makes unit testing easier.
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();
}
}
from this post:
change format from wav to mp3 in memory stream in NAudio
I understand the syntax, mostly, but I'm so green that I'm struggling to understand how to get the wavFile into the method.
Its basic C# stuff I'm obviously struggling with, and this is the first time I've been compelled to ask, but i just have to know!
Just look at that beautiful code!
Cheers Andrew