Amit Mandloi Amit Mandloi - 4 months ago 26
iOS Question

How to convert .caf file to .wav or .wma file using this code POVoiceHUD on GitHub

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.

Answer

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