简体   繁体   English

iOS中的录音格式

[英]Audio recording formats in ios

Which audio format is small in size for speech recording in ios? 哪种音频格式的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 - 假设您打算使用AVAudioRecorder类,则应提供如下录音设置-

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. Apple的文档提供了有关可在应用程序中使用的设置常量(特别是AVEncoderAudioQualityKey )的详细信息。

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. 在相同的位深度下,单声道22.05KHz足以满足语音要求,是立体声44.1KHz大小的1/4。 You could likely even try dropping it down to 11.025KHz. 您甚至可能尝试将其降低到11.025KHz。

Several iOS apps use the Speex encoder for lower-bit rate speech. 多个iOS应用程序将Speex编码器用于较低比特率的语音。 It's not built-in, but open source source code is available to do the encoding. 它不是内置的,但是可以使用开源代码进行编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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