Convert recorded sound file to flac format (xamari

2019-05-28 13:03发布

问题:

I record the sound of on iPhone using AvAudioRecorder (xamarin). How convert audio file to .FLAC format using C# (for google speech api) ?

回答1:

There isn't a C# wav-to-flac converter right now.

You could simply use FLACiOS with wav-to-flac files embedded into a project in xcode.

Then use native binding of

public partial class NativeMethods 
{
    [DllImport("__Internal", 
        EntryPoint="convertWavToFlac", 
        CallingConvention = CallingConvention.Cdecl)]
    public static extern int FlacEncode(
        [MarshalAs(UnmanagedType.LPStr)] string wav_file, 
        [MarshalAs(UnmanagedType.LPStr)] string flac_file) ;

}

and just use bound native method to convert your wav to flac.



回答2:

There are number of open source C# managed encoders, please check FlacBox or C# Flake. See also Discussion on the latter