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

Bug on Flutter Web #242

Closed marciovalim closed 2 years ago

marciovalim commented 2 years ago

TypeError: result[$item] is not a function at speech_to_text_web.SpeechToTextPlugin.new.[_onResult] (http://localhost:57473/packages/speech_to_text/speech_to_text_web.dart.lib.js:143:36) at http://localhost:57473/packages/speech_to_text/speech_to_text_web.dart.lib.js:97:98 at Object._checkAndCall (http://localhost:57473/dart_sdk.js:5246:16) at Object.dcall (http://localhost:57473/dart_sdk.js:5251:17) at SpeechRecognition. (http://localhost:57473/dart_sdk.js:100646:100)

phonghoang2k commented 2 years ago

i've got the same issue, looking for help.

marciovalim commented 2 years ago

@phonghoang2k if you find any answer, please tell me

sowens-csd commented 2 years ago

Can you give me some details to help make this reproducible?

phonghoang2k commented 2 years ago

Please check this issue. I got all when start listening.

sowens-csd commented 2 years ago

Thanks, I've reproduced it, looking for a cause now.

sowens-csd commented 2 years ago

As far as I can tell something has gone wrong with the Flutter JS binding for the speech recognition API. This definitely used to work in previous Flutter versions. I just filed an issue with the Flutter team hoping they can give me some guidance. The issue is here https://github.com/flutter/flutter/issues/86621. Feel free to upvote if this is causing you problems.

sowens-csd commented 2 years ago

For those following along here the bug has been accepted by the initial review as a regression in Flutter, see the issue linked above. If you need Web support for speech recognition currently you'll need to stick with Flutter 2.0.6 or before. I'm hopeful that a patch to the 2.2.x series will fix the regression but I have no idea how quickly regressions are addressed.

proddam commented 2 years ago

BTW https://github.com/csdcorp/speech_to_text/tree/main/multi_platform_example works with Flutter 2.2.3 in my Chrome web browser. But if I create a new flutter project and copy main.dart and speech_main.dart into the project and run, I got the same exception. @sowens-csd Have you tried the multi_platform_example with Flutter 2.2.3?

Here is my flutter doctor -v output:

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-KR)
    • Flutter version 2.2.3 at /Users/abcdef/Projects/flutter/flutter
    • Framework revision f4abaa0735 (4 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/abcdef/Library/Android/sdk
    • Platform android-30, build-tools 29.0.3
    • ANDROID_HOME = /Users/abcdef/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.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.8+10-b944.6916264)

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

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.107

• No issues found!
sowens-csd commented 2 years ago

Thanks @proddam I'm not sure what's going on, I am pretty sure I had reproduced the failure in that app previously. However, I just tried it expecting to find that it fails and I am very surprised that it worked for me as well. The only difference I can think of right now is that multi_platform_example has a relative reference to the plugin while in a new project there is a reference to the release version on pub.dev. I'll try a dependency on the repo and see what happens there.

marciovalim commented 2 years ago

@sowens-csd any update?

tuanduy183 commented 2 years ago

i encountered this bug at localhost. Then i deploy and bug is fixed :))

marciovalim commented 2 years ago

For me it continues not working @tuanduy183

edwinyoo44 commented 2 years ago

i encountered this bug at localhost. Then i deploy and bug is fixed :))

I just tried it once and nothing can be done. What is your version?

k00na commented 2 years ago

Same probleme here, a fix would be very welcome :)

sowens-csd commented 2 years ago

Sorry folks, the issue remains open on the Flutter issue list. They seem to have identified the exact commit that introduced the problem but I see nothing that would indicate that a fix is even available in a patch yet. That's pretty bad given that the issue was identified back in July and they agreed that it's a clear regression. Because Flutter has mapped all of the speech APIs for the web they have to be the ones that resolve it.

sowens-csd commented 2 years ago

Finally some good news on this. The Flutter team has suggested a work around for the issue. I've just committed a possible fix. This is working in the example app on Chrome. If anyone else could try this fix out in other environments and in their owns apps that would be very helpful. Once we confirm this is working I'll push an update to pub.dev.

sowens-csd commented 2 years ago

5.3.0 is now on pub.dev. I'm going to close this, mostly so I get a feeling of accomplishment. If anyone has issues with the web please open a new issue.