When I use RecordRTC to record audio. On Chrome I get wav file, on firefox I get ogg file. So I want to know how to convert ogg to wav in C#?
在 C# 中,您可以使用NAudio库在格式之间进行转换
static void ToWav()
{
string fileName = @"e:\down\male.ogg";
using (DsReader dr = new DsReader(fileName))
{
if (dr.HasAudio)
{
IntPtr format = dr.ReadFormat();
using (WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"),
AudioCompressionManager.FormatBytes(format)))
{
byte[] data = dr.ReadData();
ww.WriteData(data);
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.