1

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.

2 Answers2

0

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!

Community
  • 1
  • 1
Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
0

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];