iOS 语音转文本 AVAudioInputNode(?) 随机崩溃
iOS Speech-to-text AVAudioInputNode(?) random crash
我的应用程序中有语音转文本功能,请按住按钮; viewcontroller 从窗口边界外动画进入视图并开始录制,松开按钮;录制停止,视图在窗口范围外动画显示。
突然,我通过 Firebase Crash 收到一些崩溃报告,报告该功能在某些用户(2 个用户/5 个实例,所有同一事件)上崩溃。下面是我的崩溃日志事件指向我的代码。 . 但是,我根本无法重现该错误,我可能已经尝试了 1000 次,压力加载(猴子按钮捣碎它等),它不会在我的设备上崩溃..
任何人都可以帮我剖析底部的堆栈跟踪/建议吗? / 对出了什么问题有建议吗?我可以做些什么来稳定?
据我了解,它围绕 installTapOnBus:0?对下一步有什么建议吗?
_audioEngine = [[AVAudioEngine alloc] init];
_speechRecognizer = [[SFSpeechRecognizer alloc] initWithLocale:[NSLocale localeWithLocaleIdentifier:@"da"]];
[_speechRecognizer setDelegate:self];
_request = [[SFSpeechAudioBufferRecognitionRequest alloc] init];
AVAudioInputNode *node =[_audioEngine inputNode];
AVAudioFormat *recordingFormat = [node outputFormatForBus:0];
[node installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
[_request appendAudioPCMBuffer:buffer];
}];
}
堆栈跟踪:
1 CoreFoundation __exceptionPreprocess + 1232864
2 libobjc.A.dylib objc_exception_throw + 34100
3 CoreFoundation +[NSException raise:format:arguments:] + 1232560
4 AVFAudio AVAE_RaiseException(NSString*, ...) + 78280
5 AVFAudio AVAudioNodeImplBase::CreateRecordingTap(unsigned long, unsigned int, AVAudioFormat*, void (AVAudioPCMBuffer*, AVAudioTime*) block_pointer) + 554488
6 AVFAudio -[AVAudioNode installTapOnBus:bufferSize:format:block:] + 545144
7 shoppinglist 4295363296 + 297696
8 shoppinglist 4295358408 + 292808
9 UIKit -[UIViewController loadViewIfRequired] + 65212
10 UIKit -[UIViewController view] + 64152
11 shoppinglist 4295296168 + 230568
12 shoppinglist 4295272504 + 206904
13 shoppinglist 4295266368 + 200768
14 UIKit -[UIViewController _setViewAppearState:isAnimating:] + 162800
15 UIKit -[UIViewController __viewWillAppear:] + 162144
16 UIKit __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 3540196
17 UIKit _runAfterCACommitDeferredBlocks + 2738508
18 UIKit _cleanUpAfterCAFlushAndRunDeferredBlocks + 2681320
19 UIKit _afterCACommitHandler + 9796
20 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 895396
21 CoreFoundation __CFRunLoopDoObservers + 886316
22 CoreFoundation __CFRunLoopRun + 887416
23 CoreFoundation CFRunLoopRunSpecific + 36256
24 GraphicsServices GSEventRunModal + 49264
25 UIKit UIApplicationMain + 479316
26 shoppinglist 4295262124 + 196524
27 libdyld.dylib start + 17816
我也遇到过同样的崩溃,但现在已修复。所以你需要检查音频格式的速率:
AVAudioInputNode *node =[_audioEngine inputNode];
AVAudioFormat *recordingFormat = [node outputFormatForBus:0];
if (recordingFormat.sampleRate > 0)
{
[node installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
[_request appendAudioPCMBuffer:buffer];
}];
}
我的应用程序中有语音转文本功能,请按住按钮; viewcontroller 从窗口边界外动画进入视图并开始录制,松开按钮;录制停止,视图在窗口范围外动画显示。
突然,我通过 Firebase Crash 收到一些崩溃报告,报告该功能在某些用户(2 个用户/5 个实例,所有同一事件)上崩溃。下面是我的崩溃日志事件指向我的代码。 . 但是,我根本无法重现该错误,我可能已经尝试了 1000 次,压力加载(猴子按钮捣碎它等),它不会在我的设备上崩溃..
任何人都可以帮我剖析底部的堆栈跟踪/建议吗? / 对出了什么问题有建议吗?我可以做些什么来稳定?
据我了解,它围绕 installTapOnBus:0?对下一步有什么建议吗?
_audioEngine = [[AVAudioEngine alloc] init];
_speechRecognizer = [[SFSpeechRecognizer alloc] initWithLocale:[NSLocale localeWithLocaleIdentifier:@"da"]];
[_speechRecognizer setDelegate:self];
_request = [[SFSpeechAudioBufferRecognitionRequest alloc] init];
AVAudioInputNode *node =[_audioEngine inputNode];
AVAudioFormat *recordingFormat = [node outputFormatForBus:0];
[node installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
[_request appendAudioPCMBuffer:buffer];
}];
}
堆栈跟踪:
1 CoreFoundation __exceptionPreprocess + 1232864
2 libobjc.A.dylib objc_exception_throw + 34100
3 CoreFoundation +[NSException raise:format:arguments:] + 1232560
4 AVFAudio AVAE_RaiseException(NSString*, ...) + 78280
5 AVFAudio AVAudioNodeImplBase::CreateRecordingTap(unsigned long, unsigned int, AVAudioFormat*, void (AVAudioPCMBuffer*, AVAudioTime*) block_pointer) + 554488
6 AVFAudio -[AVAudioNode installTapOnBus:bufferSize:format:block:] + 545144
7 shoppinglist 4295363296 + 297696
8 shoppinglist 4295358408 + 292808
9 UIKit -[UIViewController loadViewIfRequired] + 65212
10 UIKit -[UIViewController view] + 64152
11 shoppinglist 4295296168 + 230568
12 shoppinglist 4295272504 + 206904
13 shoppinglist 4295266368 + 200768
14 UIKit -[UIViewController _setViewAppearState:isAnimating:] + 162800
15 UIKit -[UIViewController __viewWillAppear:] + 162144
16 UIKit __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 3540196
17 UIKit _runAfterCACommitDeferredBlocks + 2738508
18 UIKit _cleanUpAfterCAFlushAndRunDeferredBlocks + 2681320
19 UIKit _afterCACommitHandler + 9796
20 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 895396
21 CoreFoundation __CFRunLoopDoObservers + 886316
22 CoreFoundation __CFRunLoopRun + 887416
23 CoreFoundation CFRunLoopRunSpecific + 36256
24 GraphicsServices GSEventRunModal + 49264
25 UIKit UIApplicationMain + 479316
26 shoppinglist 4295262124 + 196524
27 libdyld.dylib start + 17816
我也遇到过同样的崩溃,但现在已修复。所以你需要检查音频格式的速率:
AVAudioInputNode *node =[_audioEngine inputNode];
AVAudioFormat *recordingFormat = [node outputFormatForBus:0];
if (recordingFormat.sampleRate > 0)
{
[node installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
[_request appendAudioPCMBuffer:buffer];
}];
}