public string ConvertToWav(string fileName) { FileInfo outputFormat = new FileInfo { FileType = FileType.Wav, Channels = 1, SampleSizeInBits = 8, SamplingRate = _samplingRate, EncodingType = EncodingType.UnsignedInteger }; var fileNameExt = Path.GetExtension(fileName); ConvertOptions convertOptions = new ConvertOptions { InputFileInfo = new FileInfo { FileType = Sox.GetFileTypeFromExtension(fileNameExt) }, OutputFileInfo = outputFormat }; using (Stream input = File.OpenRead(fileName)) { string resultFileName = Path.GetTempFileName(); _sox.Convert(input, convertOptions).WriteToFile(resultFileName); return resultFileName; } }
public Stream Convert(string fileName) { FileInfo rawFileFormat = new FileInfo { FileType = FileType.RawUnsignedInteger8, Channels = 1, SampleSizeInBits = 8, SamplingRate = _samplingRate, EncodingType = EncodingType.UnsignedInteger }; var fileNameExt = Path.GetExtension(fileName); ConvertOptions convertOptions = new ConvertOptions { InputFileInfo = new FileInfo { FileType = Sox.GetFileTypeFromExtension(fileNameExt) }, OutputFileInfo = rawFileFormat }; using (Stream input = File.OpenRead(fileName)) { return _sox.Convert(input, convertOptions); } }
public Stream Convert(string fileName) { FileInfo rawFileFormat = new FileInfo { FileType = FileType.RawUnsignedInteger8, Channels = 1, SampleSizeInBits = 8, SamplingRate = _samplingRate, EncodingType = EncodingType.UnsignedInteger }; var fileNameExt = Path.GetExtension(fileName); ConvertOptions convertOptions = new ConvertOptions { InputFileInfo = new FileInfo { FileType = Sox.GetFileTypeFromExtension(fileNameExt) }, OutputFileInfo = rawFileFormat }; using (Stream input = File.OpenRead(fileName)) { return(_sox.Convert(input, convertOptions)); } }
public string ConvertToWav(string fileName) { FileInfo outputFormat = new FileInfo { FileType = FileType.Wav, Channels = 1, SampleSizeInBits = 8, SamplingRate = _samplingRate, EncodingType = EncodingType.UnsignedInteger }; var fileNameExt = Path.GetExtension(fileName); ConvertOptions convertOptions = new ConvertOptions { InputFileInfo = new FileInfo { FileType = Sox.GetFileTypeFromExtension(fileNameExt) }, OutputFileInfo = outputFormat }; using (Stream input = File.OpenRead(fileName)) { string resultFileName = Path.GetTempFileName(); _sox.Convert(input, convertOptions).WriteToFile(resultFileName); return(resultFileName); } }
public string ConvertToWav(string sourceFileName, string destinationFileName, bool highQuality = false) { _log.Debug(string.Format("Atempting to convert '{0}' to '{1}'", sourceFileName, destinationFileName)); FileInfo outputFormat = new FileInfo { FileType = FileType.Wav, Channels = 1, SampleSizeInBits = 8, SamplingRate = highQuality ? SAMPLING_RATE * 2 : SAMPLING_RATE, EncodingType = EncodingType.UnsignedInteger }; var fileNameExt = Path.GetExtension(sourceFileName); ConvertOptions convertOptions = new ConvertOptions { InputFileInfo = new FileInfo { FileType = Sox.GetFileTypeFromExtension(fileNameExt) }, OutputFileInfo = outputFormat }; using (Stream input = File.OpenRead(sourceFileName)) { string resultFileName = string.IsNullOrEmpty(destinationFileName) ? Path.GetTempFileName() : destinationFileName; using (var tempConvertedFileStream = _sox.Convert(input, convertOptions)) { tempConvertedFileStream.WriteToFile(resultFileName); }; return(resultFileName); } }
public string ConvertToWav(string sourceFileName, string destinationFileName, bool highQuality = false) { _log.Debug(string.Format("Atempting to convert '{0}' to '{1}'", sourceFileName, destinationFileName)); FileInfo outputFormat = new FileInfo { FileType = FileType.Wav, Channels = 1, SampleSizeInBits = 8, SamplingRate = highQuality ? SAMPLING_RATE * 2 : SAMPLING_RATE, EncodingType = EncodingType.UnsignedInteger }; var fileNameExt = Path.GetExtension(sourceFileName); ConvertOptions convertOptions = new ConvertOptions { InputFileInfo = new FileInfo { FileType = Sox.GetFileTypeFromExtension(fileNameExt) }, OutputFileInfo = outputFormat }; using (Stream input = File.OpenRead(sourceFileName)) { string resultFileName = string.IsNullOrEmpty(destinationFileName) ? Path.GetTempFileName() : destinationFileName; using (var tempConvertedFileStream = _sox.Convert(input, convertOptions)) { tempConvertedFileStream.WriteToFile(resultFileName); }; return resultFileName; } }