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 231 forks source link

macOS Support #534

Closed alexrabin-sentracam closed 1 month ago

alexrabin-sentracam commented 2 months ago

Addresses https://github.com/csdcorp/speech_to_text/issues/231

This pr adds macOS support with a HUGE caveat.

This functionality only works when running the app directly from Xcode. There is a known issue with flutter that the macOS app crashes when requesting permissions in VSCode https://github.com/flutter/flutter/issues/70374.

I leave this up to the author on if they want to merge this or not. But the functionality does exist.

alexrabin-sentracam commented 2 months ago

@sowens-csd I was able to implement macOS support by using the shared Darwin approach as mentioned in the flutter docs: https://docs.flutter.dev/packages-and-plugins/developing-packages#shared-ios-and-macos-implementations. Both iOS and macOS use the same code with some slight differences based off their platforms.

Take a look at the speech_to_text/darwin/Classes/SpeechToTextPlugin.swift file for the implementation.

alibad commented 1 month ago

@sowens-csd any plans to merge and launch it in a new version of the flutter package?

Are you aware of speech_to_text_macos?

alexrabin-sentracam commented 1 month ago

@alibad "speech_to_text_macos" is no longer needed because of the shared darwin implementation in this pr

alexrabin-sentracam commented 1 month ago

@alibad I ran the example projects on iOS and macOS on my Mac. I made sure text was returned from the plugin.

alibad commented 1 month ago

@sowens-csd can you please approve this change? I'd like to use it as soon as the new version comes out.

sowens-csd commented 1 month ago

@alexrabin-sentracam I've merged the PR and am trying to run the example on MacOS. I've tried it from Xcode after a clean build and the app appears but clicking initialize does not appear to do anything. No errors in the log.

So far I've been unable to get the debugger to stop on any lines inside the .swift. Any tips on how you tested that might help?

alexrabin-sentracam commented 1 month ago

@sowens-csd I pulled the latest code and I was able to get it to work correctly in Xcode. What macOS version are you on? I am on macOS 14.5

alexrabin-sentracam commented 1 month ago

@sowens-csd make sure to run

flutter pub get and cd macos && pod install It's possible your local is still pointing to the old speech_to_text_macos plugin

sowens-csd commented 1 month ago

Thanks for the assist, working well now. I'll add that to the README in case anyone is as much of an idiot as I. Thanks so much for doing this work. It's going to be in the 7.0.0 release of the plugin.

alexrabin-sentracam commented 1 month ago

Happy to help!

alibad commented 1 month ago

Exciting! @sowens-csd when will the 7.0.0 release of the plugin take place? I'd like to pull it right away to test the MacOS behavior.

sowens-csd commented 1 month ago

7.0.0-beta.1 is available now.

alibad commented 1 month ago

I just tested the beta. Before, I would get an initialize error. Now, the app crashes without any errors logged

sowens-csd commented 1 month ago

Did you run it from Xcode or VSCode? There's apparently a permissions problem that prevent Mac apps from working unless run from Xcode.

alibad commented 1 month ago

Yes, it works from there

alexrabin-sentracam commented 1 month ago

@sowens-csd you might want to mention higher up in the ReadMe that MacOS only works when being run from Xcode.