简体   繁体   中英

Audio recording formats in ios

Which audio format is small in size for speech recording in ios? The quality is need not to be the best but it should be understandable what user speaks.

Assuming you plan to use AVAudioRecorder class, you should provide the recording settings like so -

NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
    [NSNumber numberWithInt:16], AVEncoderBitRateKey,
    [NSNumber numberWithInt: 2],AVNumberOfChannelsKey,
    [NSNumber numberWithFloat:44100.0], AVSampleRateKey,nil];


NSError* error = nil;
AVAudioRecorder audioRecorder = [[AVAudioRecorder alloc]  
                                  initWithURL:soundFileURL 
                                  settings:recordSettings
                                  error:&error];

Apple's documentation provides details about the settings constants (specifically AVEncoderAudioQualityKey ) you could use in your app.

22.05KHz in mono is more than adequate for speech and is 1/4 the size of 44.1KHz in stereo at the same bit depth. You could likely even try dropping it down to 11.025KHz.

Several iOS apps use the Speex encoder for lower-bit rate speech. It's not built-in, but open source source code is available to do the encoding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM