I am working on audio recording. I am able to record my audio in .caf (Core audio format)and later I need to convert it to .wav or .wma in order to upload the file on FTP Server. How can I convert the file to .wav or .wma format in iOS? Using POVoiceHUD code from GitHub. Can any one help me to solve my problem.
-
[http://stackoverflow.com/questions/19119422/convert-caf-file-to-wav-file-with-progress-bar-in-ios](http://stackoverflow.com/questions/19119422/convert-caf-file-to-wav-file-with-progress-bar-in-ios) – Ketan Parmar Aug 05 '16 at 13:26
-
I try this code but not working in project(POVoiceHUD). – Amit Mandloi Aug 05 '16 at 13:41
-
Check my update in answer! – Ketan Parmar Aug 05 '16 at 13:59
2 Answers
If you want to convert the .caf to .wav then you can refer this SO post as i have mentioned in comment also.
But if you want your audio as a .wav or .wma to send on server or for whatever purpose then why you are not recording it in .wav or .wma format from starting. If you will do like then you will not need to convert it.
Second thing you can record your audio in .wav or .wma format only just giving extension
as .wav
or .wma
to your path
or url
where you are storing your video and which you are passing in your AVAudioRecorder
object.
for example,
NSString *folderPath = NSTemporaryDirectory();
NSString *soundFilePath = [folderPath
stringByAppendingPathComponent:[NSString stringWithFormat: @"%.0f%@", [NSDate timeIntervalSinceReferenceDate] *1000.0, @"audio.wav"]];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSLog(@"Using File called: %@",soundFileURL);
audioRecorder = [[ AVAudioRecorder alloc] initWithURL:soundFileURL settings:recordSetting error:&error];
[audioRecorder setDelegate:self];
[audioRecorder prepareToRecord];
Update :
I have visited POVoiceHUd,
Just Try to replace below line
[self.voiceHud startForFilePath:[NSString stringWithFormat:@"%@/Documents/MySound.caf", NSHomeDirectory()]];
with
[self.voiceHud startForFilePath:[NSString stringWithFormat:@"%@/Documents/MySound.wav", NSHomeDirectory()]];
And it will store audio in .wav
format i think!

- 1
- 1

- 27,092
- 9
- 50
- 75
-
It does not working, because in this method startForFilePath: some file extention are given. – Amit Mandloi Aug 05 '16 at 14:12
First you have to change save file extension .caf to .wav in below line given
[self.voiceHud startForFilePath:[NSString stringWithFormat:@"%@/Documents/MySound.wav", NSHomeDirectory()]];
Then goto the method (startForFilePath:) change the settings for the voice quality.
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:8000.0], AVSampleRateKey,
[NSNumber numberWithInt:8], AVLinearPCMBitDepthKey,
nil];

- 13
- 6