How to change audio recording settings to 16Khz and 16 bit when we record audio?

早过忘川 提交于 2019-12-06 09:13:53

Your existing settings are 44.1kHz and 16 bit so (assuming the above already works) the only line you'd need to change is:

[NSNumber numberWithFloat:44100.0] 

To:

[NSNumber numberWithFloat:16000.0]

Try this, General Audio settings are,

AVFormatIDKey,
AVSampleRateKey,
AVNumberOfChannelsKey.

And for Audio recorder

AVEncoderAudioQualityKey;
AVEncoderBitRateKey;
AVEncoderBitRatePerChannelKey;
AVEncoderBitDepthHintKey;

make sure you have included general and recorder settings.

and change your AVSampleRateKey to 16000.0,

NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:                 
                                [NSNumber numberWithInt:kAudioFormatLinearPCM],
                                AVFormatIDKey
                                [NSNumber numberWithInt: 2],
                                AVNumberOfChannelsKey,
                                [NSNumber numberWithFloat:16000.0],
                                AVSampleRateKey,
                                [NSNumber numberWithInt:AVAudioQualityMin],
                                AVEncoderAudioQualityKey,
                                [NSNumber numberWithInt:16],
                                AVEncoderBitRateKey,
                                nil];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!