I have been searching for the C# library or code sample which could help me to do the conversion of m4a
audio file to flac
, but more importantly with sample rate (of 16000), mono channel and bit resolution of either 16 or 24.
Right now, I have found library solutions like NAudio, MediaToolKit and SOXSharp
. But I cannot get enough information how to use them accordingly.
I needed those converted audio files for Google Cloud speech to text API inputs.
I have found this great website where I can convert files manually and they are working great with API.
Is there any C# library which can help to convert .M4A audio file to .FLAC?
I was able to solve this issue with library FFMpeg.Net and FFMpeg.
Install on windows guide here.
and then in code
var inputFile = new MediaFile (@"C:\file.m4a");
var outputFile = new MediaFile (@"C:\file.flac");
var ffmpeg = new Engine("C:\\ffmpeg\\ffmpeg.exe");
await ffmpeg.ConvertAsync(inputFile, outputFile);
Beware there might be file write permission denied error when writing to c://
and windows environment variable
.