File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ - (void) setupAndStartRecognizing:(NSString*)localeStr {
163163 self.audioEngine = [[AVAudioEngine alloc ] init ];
164164 }
165165
166+ @try {
166167 AVAudioInputNode* inputNode = self.audioEngine .inputNode ;
167168 if (inputNode == nil ) {
168169 [self sendResult: @{@" code" : @" input" } :nil :nil :nil ];
@@ -223,8 +224,6 @@ - (void) setupAndStartRecognizing:(NSString*)localeStr {
223224 @try {
224225 [mixer installTapOnBus: 0 bufferSize: 1024 format: recordingFormat block: ^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
225226 // Volume Level Metering
226- // Buffer frame can be reduced, if you need more output values
227- [buffer setFrameLength: buffer.frameCapacity];
228227 UInt32 inNumberFrames = buffer.frameLength ;
229228 float LEVEL_LOWPASS_TRIG = 0.5 ;
230229 if (buffer.format .channelCount >0 )
@@ -272,6 +271,11 @@ - (void) setupAndStartRecognizing:(NSString*)localeStr {
272271 [self teardown ];
273272 return ;
274273 }
274+ }
275+ @catch (NSException *exception) {
276+ [self sendResult: @{@" code" : @" start_recording" , @" message" : [exception reason ]} :nil :nil :nil ];
277+ return ;
278+ }
275279}
276280
277281- (CGFloat)_normalizedPowerLevelFromDecibels : (CGFloat)decibels {
You can’t perform that action at this time.
0 commit comments