Hi sani.ss501,
You can implement by using Use NAudio.
1. First install the NAudio from Nuget.
2. Then add the WaveFormRendererLib to your project.
WaveFormRendererLib
Check this example. Now please take its reference and correct your code.
Namespaces
using System.Drawing.Imaging;
using System.Drawing;
using NAudio.Wave;
using NAudio.WaveFormRenderer;
Controller
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
MaxPeakProvider maxPeakProvider = new MaxPeakProvider();
RmsPeakProvider rmsPeakProvider = new RmsPeakProvider(200);
SamplingPeakProvider samplingPeakProvider = new SamplingPeakProvider(200);
AveragePeakProvider averagePeakProvider = new AveragePeakProvider(4);
StandardWaveFormRendererSettings myRendererSettings = new StandardWaveFormRendererSettings();
myRendererSettings.Width = 1080;
myRendererSettings.TopHeight = 64;
myRendererSettings.BottomHeight = 64;
WaveFormRenderer renderer = new WaveFormRenderer();
string audioFilePath = Server.MapPath("~/MP3/Test.mp3");
Image image = renderer.Render(audioFilePath, averagePeakProvider, myRendererSettings);
string path = System.IO.Path.Combine(Server.MapPath("~"), "MP3/Test.png");
image.Save(path, ImageFormat.Png);
ViewBag.Path = "MP3/Test.png";
return View();
}
}
View
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@if (ViewBag.Path != null)
{
<img src="@ViewBag.Path" alt="Alternate Text" width="100%" />
}
</body>
</html>
Screenshot
Reference:
https://ourcodeworld.com/articles/read/750/how-to-render-an-audio-wave-image-from-a-mp3-audio-file-with-naudio-in-c-sharp-winforms