Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get locales on Android #505

Open
FaFre opened this issue Apr 10, 2024 · 12 comments
Open

Can't get locales on Android #505

FaFre opened this issue Apr 10, 2024 · 12 comments

Comments

@FaFre
Copy link

FaFre commented Apr 10, 2024

I tried to run the example but the call SpeechToTextPlatform.instance.locales() is never returning on my device. I tried several rebuilds and reinstalls, but it wouldn't work. I have two languages offline installed. I tried to fish with logcat, but there is nothing. Flutter is not throwing anything as well.

Edit: Tag v6.2.0 is working (but only showing one of my two available languages), all version above are not working. I'm on Flutter 3.21.0-1.0.pre.2

Edit: After setting up a new example I can identify that the following version breaks the locales platform call on my device (Android 13):

Android 33+ now returns a valid list from locales. It returns the supported on device languages. This is (probably) smaller than the full list of online languages but better than the current list that only has the default language in it. It also seems to be the only option that's available.
@sowens-csd
Copy link
Contributor

Is this on a real device or a simulator? If real which device?

I'm definitely not happy with that method of getting the locales. Sure wish Android with fix the default previously working method or implement their suggested new method consistently. However, I've never seen it just hang. That's very surprising. Can you do a run with debugLogging: true in the initialize call and post the log output?

@FaFre
Copy link
Author

FaFre commented Apr 11, 2024

This is on a real device Xiaomi Poco F3 (M2012K11AG). I use LineageOS 20 (Android 13) with all available Android patches until 05.04.2024, so the System is very up-to date.

This is the output:

D/SpeechToTextPlugin(11005): Start initialize
D/SpeechToTextPlugin(11005): Checked permission
D/SpeechToTextPlugin(11005): has permission, completing
D/SpeechToTextPlugin(11005): completeInitialize
D/SpeechToTextPlugin(11005): Testing recognition availability
D/BluetoothHeadset(11005): Binding service...
D/SpeechToTextPlugin(11005): sending result
D/SpeechToTextPlugin(11005): leaving complete
D/SpeechToTextPlugin(11005): leaving initializeIfPermitted
D/BluetoothHeadset(11005): Proxy object connected
D/SpeechToTextPlugin(11005): Found a headset: android.bluetooth.BluetoothHeadset@1be0189
I/Gralloc4(11005): Adding additional valid usage bits: 0x546c08202000

I should have everything set up:

Screenshot_20240411-092222_Settings
Screenshot_20240411-092159_Google
Screenshot_20240411-092140_Google
Screenshot_20240411-092131_Speech Recognition and Synthesis from Google

@sowens-csd
Copy link
Contributor

So on newer Android builds locales are retrieved using on device speech recognition if it is available. From what I've seen in the past some devices, possibly including Xiaomi do not fully implement all parts of Android. I think there is/was some disagreement with Google that blocked it. I wonder if the on device speech recognition is not working. I'll have a look at the way it looks up the on device and see if maybe it's failing to catch an exception or something there.

@FaFre
Copy link
Author

FaFre commented Apr 14, 2024

I'm using LineageOS which should be almost vanilla Android.

@FaFre
Copy link
Author

FaFre commented Apr 14, 2024

@sowens-csd when you can give me a bit of guidance on how to debug it, I will happily do it. I'm just not really familiar with native android to build up a small test application with ease.

@sowens-csd
Copy link
Contributor

Thanks for the offer. I’d love to work with you on it. Unfortunately it will be a few weeks. I’ll post again when I can work on it. Sorry for the delay.

@Solorwind
Copy link

same issue. anything update?
I have specified the local , it work.
image

截屏2024-09-02 09 56 32

@FaFre
Copy link
Author

FaFre commented Sep 2, 2024

@Solorwind I didn't find a solution and moved to another library. Google now offers a very simply voice input sheet on Android that only requires a single call. But since you seem to target iOS, I cannot help you out with that.

@Mahim-Khan
Copy link

@Solorwind I didn't find a solution and moved to another library. Google now offers a very simply voice input sheet on Android that only requires a single call. But since you seem to target iOS, I cannot help you out with that.

Can you please tell me which library you have moved into

@FaFre
Copy link
Author

FaFre commented Oct 9, 2024

@tudosxxx
Copy link

I have the same problem, and the strange thing is that I was able to get a lot of language lists last week, but now I can only get one language.

@tudosxxx
Copy link

await speechToText.initialize(
debugLogging: true,
options: [
if(Platform.isAndroid)SpeechToText.androidIntentLookup,
]
);
locales = await speechToText.locales();

And on Samsung phones you must add this SpeechToText.androidIntentLookup,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants