I write some voice to the docs folder using the following methods
func record() { self.prepareToRecord() if let recorder = self.audioRecorder { recorder.record() } } let recordSettings = [ AVSampleRateKey : NSNumber(float: Float(44100.0)), AVFormatIDKey : NSNumber(int: Int32(kAudioFormatAppleLossless)), AVNumberOfChannelsKey : NSNumber(int: 2), AVEncoderAudioQualityKey : NSNumber(int: Int32(AVAudioQuality.Medium.rawValue)), AVEncoderBitRateKey : NSNumber(int: Int32(320000)) ] func prepareToRecord() { let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString let soundFileURL: NSURL? = NSURL.fileURLWithPath("\(documentsPath)/recording.caf") print("\(soundFileURL)") self.audioRecorder = try! AVAudioRecorder(URL: soundFileURL!, settings: recordSettings) if let recorder = self.audioRecorder { recorder.prepareToRecord() } }
This method will save the audio file as record.caf in the document directory, but I want to convert this record.caf file to mp3 for further manipulations.
How to convert this .caf file to .mp3 in swift?
source share