gpt4 book ai didi

ios - AVAudioRecorder 没有将录音保存到指定的路径

转载 作者:行者123 更新时间:2023-11-28 22:07:34 32 4
gpt4 key购买 nike

我正在使用 AVAudioRecorder 录制音频,它录制流畅,我可以播放或获取保存文件我正在使用以下代码初始化 AVAudioRecorder

 NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
[NSNumber numberWithInt:AVAudioQualityLow], AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16], AVEncoderBitRateKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithFloat:16000], AVSampleRateKey,
nil];

NSArray *searchPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath_ = [searchPaths objectAtIndex: 0];
NSString *pathToSave = [documentPath_ stringByAppendingPathComponent:[self dateString]];

self.pathfinal = pathToSave;
NSURL *url = [NSURL fileURLWithPath:pathToSave];
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];

if (!recorder)
{
return NO;
}
recorder.delegate = self;
recorder.meteringEnabled = YES;
if (![recorder prepareToRecord])
{
return NO;
}

if (![recorder record])
{
return NO;
}

但是我的一些客户在停止录制时遇到了一个问题(它将保存在磁盘上的步骤)它不会保存任何它创建的文件但每次录制时都没有数据。

但是当使用不同的 iPhone 时,这不是问题。 iPhone 有 2gb 可用硬盘空间。知道是什么原因造成的吗?

最佳答案

就我而言,只需尝试使用 AVEncoderBitRateKey 即可解决问题。

查看此 question .

关于ios - AVAudioRecorder 没有将录音保存到指定的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23577369/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com