csdcorp / speech_to_text

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

"error_listen_failed" using iOS simulator and null safety versions #290

Closed joseplazatb closed 10 months ago

joseplazatb commented 2 years ago

Hi, The speech to text is not working at all for me using the iOS simulator since I updated to the latest version (tested all the null-safety versions from 4.2.0). Neither the sample code nor my code works. I'm using flutter version 2.8.1. I just receive the following error:

error_listen_failed, permanent: true, listening: false

If I build the .ipa and install it in a physical device it works. Tested in simulators with iOS version 15.0 and 15.2, in both Intel and M1 computers. Previously my app ran with 3.2.0 version (non null-safety) without issues.

Just to be sure, I created a new flutter project with null safety and pasted the example, using the latest version of the package, and the issue persists.

I found another related issue here https://github.com/csdcorp/speech_to_text/issues/284, but it was closed since the problem is only for simulator.

Can anyone help me? Thanks in advance!

sowens-csd commented 2 years ago

I'm exploring this now. The short answer is that yes, something has definitely changed with simulator support and I think it's on Apple's side but I'm not sure yet. Also not sure if I can work around it. I'll report back once I know more.

sowens-csd commented 2 years ago

I have more detail now but don't yet know if I can resolve it. Simulators are causing two separate problems, one is the dreaded format.sampleRate == hwFormat.sampleRate issue. There's an interesting approach suggested here that I tried and partially resolved it https://stackoverflow.com/questions/66971504/i-got-crash-when-record-required-condition-is-false-format-samplerate-hwf. The basic idea is to always convert from whatever the current sample rate is to a known sample rate using an audio converter.

Unfortunately even with that fix I started getting 1107 which doesn't seem to have a clear description or a fix, discussions of it here https://developer.apple.com/forums/thread/73256 among other places.

The other issue on simulators is a sensitivity to the simulator configuration. The only way I was able to get it partially working is to always set the simulator audio input and output to System not to a particular device.

ben-xx commented 1 year ago

@sowens-csd Just a heads-up that speech_to_text is apparently working again on iOS Simulators after updating to iOS 16.0 (installed as part of an XCode 14 update, which I didn't request, but just popped up yesterday).

On previous Simulators with iOS 15.x, speech_to_text.listen() would fail immediately for me.

After the XCode update I had to recreate my iOS iPhone Simulators from 15.6 (if I remember the version correctly), to 16.0 (the only available choice). After re-installing my app on the Simulator (which uses speech_to_text ^5.6.0 & Flutter: 2.10.5.), listening initialized OK and then correctly interpreted my voice commands. Huzzah!

This is running on OSX Monterey 12.5.1 on an Intel Mac Mini 2018 using an external microphone with Sound Input device set to "External Microphone/Microphone port". The Simulator's I/O Audio Input is set to System (External Microphone).

sowens-csd commented 1 year ago

Thanks for the update, that's really helpful.

Iverson commented 1 year ago

@sowens-csd Just a heads-up that speech_to_text is apparently working again on iOS Simulators after updating to iOS 16.0 (installed as part of an XCode 14 update, which I didn't request, but just popped up yesterday).

On previous Simulators with iOS 15.x, speech_to_text.listen() would fail immediately for me.

After the XCode update I had to recreate my iOS iPhone Simulators from 15.6 (if I remember the version correctly), to 16.0 (the only available choice). After re-installing my app on the Simulator (which uses speech_to_text ^5.6.0 & Flutter: 2.10.5.), listening initialized OK and then correctly interpreted my voice commands. Huzzah!

This is running on OSX Monterey 12.5.1 on an Intel Mac Mini 2018 using an external microphone with Sound Input device set to "External Microphone/Microphone port". The Simulator's I/O Audio Input is set to System (External Microphone).

Unfortunately, it doesn't work for me. I keep receiving "error_listen_failed" on iOS 16.0 iPhone Simulator (Intel, OSX Monterey 12.5.1).

peterpanduro commented 1 year ago

I am having the same problem as stated above. speech_to_text 6.1.0 crashes on init with sample rate issues. Before this I had the error_listen_failed on version 6.0.0.

$ flutter doctor -v
[✓] Flutter (Channel stable, 3.3.2, on macOS 12.6 21G115 darwin-x64, locale en-SE)
    • Flutter version 3.3.2 on channel stable at /Users/wanderword/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e3c29ec00c (6 weeks ago), 2022-09-14 08:46:55 -0500
    • Engine revision a4ff2c53d8
    • Dart version 2.18.1
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/wanderword/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      � https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      � https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.72.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.50.0

[✓] Connected device (3 available)
    • iPhone 14 Pro (mobile) • A174BF45-0787-42E9-9DE8-EB777D28C868 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-x64     • macOS 12.6 21G115 darwin-x64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 106.0.5249.119

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
alexobviously commented 1 year ago

I'm also getting this error since MacOS Ventura and the xcode/ios simulator update that comes with it (iphone 14)

nholmvio commented 1 year ago

likewise for me today after Ventura update and Xcode 14.

Any other new data points in last month.. What are folks doing now...

ben-xx commented 1 year ago

@alexobviously @nholmvio Did speech_to_text stop working after upgrading to Ventura OS, but was fine on Monterey? Or was there a version change on Xcode, iOS or speech_to_text as well?

I'm wondering whether it was the Monterey → Ventura that broke package operation or perhaps it's something else.

I haven't upgraded my Mac to Ventura yet and I'm using Simulator with iOS 16.1, Xcode 14.1 and speech_to_text 5.6.0 and the package is working well (starts without error & mic voice recognition/interpretation is working).

nholmvio commented 1 year ago

@ben-xx I had my voice feature disabled for quite some time. It was probably from Big Sur days and i had 5.1.0 in my pubspec(when it was last tested -edit: that may have been updated via my recent pub update when i was catching up with flutter version and was more than likely an earlier version when i using).

I came back this week to revisit on Monterey, and latest Flutter release, and the 6.1.1. and it wasn't working and saw forum posts.

Upgraded to Ventura and Xcode 14 per the thread earlier today to see if went away.

I can confirm it's running on device ok...

Thanks

alexobviously commented 1 year ago

@alexobviously @nholmvio Did speech_to_text stop working after upgrading to Ventura OS, but was fine on Monterey? Or was there a version change on Xcode, iOS or speech_to_text as well?

I'm not sure which of these - my guess is a change to the simulator. I fixed this by on my emulator forcing the sample rate to 44100 (in SpeechToText.listen), though many of our customers are still getting it in production and we can't quite figure out why.

edit: I just tried it again without the explicit sample rate and it now works so either this package got an update or simulator got fixed (customers still getting it though so not great lol)

EmmanuelQC commented 1 year ago

Still facing the same error with IOS 16.4 emulator.

Ran it with IOS 14.5 emulator and it works fine. speechToText won't initialize for some reason and glitches out. Basically can't run tests for IOS 16+ until it gets fixed.

sowens-csd commented 10 months ago

I found a resolution for using simulators. The README has an update explaining how to configure simulators for speech recognition.