csdcorp / speech_to_text

A Flutter plugin that exposes device specific text to speech recognition capability.
BSD 3-Clause "New" or "Revised" License
372 stars 230 forks source link

Unhandled Exception: Instance of 'ListenFailedException' #132

Closed javadkt closed 3 years ago

javadkt commented 4 years ago

When trying to call speech.listen getting the below error in iOS simulator:

Unhandled Exception: Instance of 'ListenFailedException'

0 SpeechToText.listen (package:speech_to_text/speech_to_text.dart:326:7)

#1 _ChatState.startListening (package:homing/screens/converse/widgets/chat.dart:1715:12) #2 _ChatState.createMessageInputComponent. (package:homing/screens/converse/widgets/chat.dart:1025:27) #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:992:19) #4 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1098:38) #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24) #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11) #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5) #8 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:219:7) #9 PrimaryPointerGestureReco<…>
sowens-csd commented 4 years ago

Check the details of the exception to see the root cause. That exception is thrown whenever there is a failure calling a plugin method from the listen method. Knowing the cause will help diagnose the problem.

sowens-csd commented 4 years ago

Any updates on this?

proddam commented 4 years ago

I got the same error when I tried to run the example app of this plugin.

iOS Simulator: iPhone SE (2nd gerneration) Xcode: v 11.7

2020-09-09 21:26:04.993467+0900 Runner[49930:1499790] [plugin] Has permissions continuing with setup
2020-09-09 21:26:06.492362+0900 Runner[49930:1500041] [VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: Instance of 'ListenFailedException'
#0      SpeechToText.listen (package:speech_to_text/speech_to_text.dart:326:7)
<asynchronous suspension>
#1      _MyAppState.startListening (package:speech/main.dart:205:12)
#2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:992:19)
#3      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1098:38)
#4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
#5      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11)
#6      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5)
#7      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:219:7)
#8      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:477:9)
#9      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:78:12)
#10     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:124:9)
#11     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#12     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:122:18)
#13     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:108:7)
#14     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:220:19)
#15     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
#16     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)
#17     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:104:7)
#18     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:88:7)
#19     _rootRunUnary (dart:async/zone.dart:1206:13)
#20     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#21     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
#22     _invoke1 (dart:ui/hooks.dart:267:10)
#23     _dispatchPointerDataPacket (dart:ui/hooks.dart:176:5)
2020-09-09 21:26:06.642387+0900 Runner[49930:1500272] [Utility] +[AFAggregator logDictationFailedWithError:] Error Domain=kAFAssistantErrorDomain Code=601 "(null)"
2020-09-09 21:26:06.642910+0900 Runner[49930:1499790] [plugin] FinishSuccessfully with error: Optional(Error Domain=kAFAssistantErrorDomain Code=601 "(null)")
2020-09-09 21:26:06.642959+0900 Runner[49930:1499790] [plugin] FinishSuccessfully
2020-09-09 21:26:06.645298+0900 Runner[49930:1499790] [plugin] invokeFlutter notifyStatus
2020-09-09 21:26:06.648095+0900 Runner[49930:1500041] flutter: Received listener status: notListening, listening: false
javadkt commented 4 years ago

Any updates on this?

It's actually hitting on the PlatformException catch. So I guess speech_to_text don't work with simulator, need to use a real device.

sowens-csd commented 4 years ago

It does work on iOS simulators. It works on Android simulators if they are properly configured. That exception provides more information if you check the details. The ListenFailedException is a wrapper.

sowens-csd commented 3 years ago

I'm going to close this since there's not enough information to do any troubleshooting. If you get details from the exception please post them and I'll reopen.

sowens-csd commented 3 years ago

Over in #139 there was a suggestion that this error can be caused by having the onDevice parameter set to true. Worth just checking your code to see if that could be the cause.

javadkt commented 3 years ago

Over in #139 there was a suggestion that this error can be caused by having the onDevice parameter set to true. Worth just checking your code to see if that could be the cause.

Thank you Sowens, onDevice: false solved the issue.

fullflash commented 1 year ago

for my the full error got from console app is

+[AFAggregator logDictationFailedWithError:] Error Domain=kAFAssistantErrorDomain Code=203 "Corrupt" UserInfo={NSLocalizedDescription=Corrupt, NSUnderlyingError=0x6000036a4b10 {Error Domain=SiriSpeechErrorDomain Code=102 "(null)"}}

with onDevice:false still getting same error