I have the settings shown below.
I want change audio recording settings to 16Khz and 16 bit when we record audio.
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString *soundFilePath = [docsDir
stringByAppendingPathComponent:@"sound.wav"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
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;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
} else
{
[audioRecorder prepareToRecord];
}
How to set those settings?
Edit the question:
Thanks for giving the replies, i tried those ways but it did not work for me, Because my client is sending the recorded voice(the recorded voice what i am sending in bytes format) to ASR engine (Automatic speech recognition). i am not getting back the same response (i am getting the response audio says "quotation mark") what i send . Client says you are not recording the voice in 16KHz and 16 bit sample rate thats why you are getting that response. But i asked him the bytes what i send to his server, He given that .wav file it is playing perfectly. But if the same one he is sending to ASR engine , the ASR engine not accepts the recorded voice what i am sending(He says that ASR wont accept because you are not recording audio in 16KHz and 16 bit sample rate). Client given the following response. (But, I tried all the ways suggested by you)
Filename: sv_SE_356985580762248932.wav
Folder: E:\developApp\TestappName\Mortionsn_dev\2nd-iteration\test_wfiles
File Type: 44100Hz, 16-bit, Stereo
Uncompressed Size: 1.63 MB (1,713,696 bytes)
File Format: Windows PCM
Windows PCM
Size on Disk: 1.63 MB (1,717,892 bytes)
Last Written (local): 3/11/2013 00:21:00.000
Length: 0:09.714
428,424 samples
Edit the question 2nd Time By using Below Answers:
Later by giving the suggestions i changed my settings code to:
NSMutableDictionary *recordSettings = [NSMutableDictionary dictionary];
[recordSettings setValue: [NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
[recordSettings setValue: [NSNumber numberWithFloat:16000.0] forKey:AVSampleRateKey];//8000.0
[recordSettings setValue: [NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];
[recordSettings setValue: [NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings setValue: [NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[recordSettings setValue: [NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
[recordSettings setValue: [NSNumber numberWithInt: AVAudioQualityMax] forKey:AVEncoderAudioQualityKey];
Your existing settings are 44.1kHz and 16 bit so (assuming the above already works) the only line you'd need to change is:
To:
Try this, General Audio settings are,
And for Audio recorder
make sure you have included general and recorder settings.
and change your
AVSampleRateKey
to16000.0
,