public async Task <WavStream> ConvertAsync(Stream stream) { var section = configuration.GetSection("AudioToTextService.Core.WavAudioConverter"); var ffmpegPath = section["ffmpeg"]; using (var inputFile = await TempFileInfo.GenTempFileAsync(stream)) { var outputFile = Path.ChangeExtension(Path.GetTempFileName(), ".wav"); var cmd = String.Format(ToWavCmdLine, inputFile.FileName, outputFile); ProcessStartInfo psi = new ProcessStartInfo(ffmpegPath, cmd) { UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = Directory.GetCurrentDirectory(), RedirectStandardOutput = true, RedirectStandardError = true }; using (Process p = Process.Start(psi)) { //* Read the output (or the error) string ffmpegOutput = p.StandardOutput.ReadToEnd(); string ffmpegErrOutput = p.StandardError.ReadToEnd(); p.WaitForExit(); if (p.ExitCode != 0) { throw new Exception(ffmpegOutput + ffmpegErrOutput); } TimeSpan ts = ParseTimeFromFFMpegOutput(ffmpegErrOutput); return(new WavStream(outputFile, FileMode.Open, FileAccess.Read, ts)); } } }