yasirkula / UnitySpeechToText

A native Unity plugin to convert speech to text on Android & iOS
MIT License
66 stars 7 forks source link

Getting Error Code 13 on some Android Devices #4

Open Aumarka opened 2 months ago

Aumarka commented 2 months ago

Description of the bug

On my Samsung A21s, the speech to text function works fine, however, when I try to run the speech to text function on a Samsung S23, it doesn't work. I outputted text for the error code and it came out as 13. From what I read it seems to be because the language is supported, but for some reason unavailable.

Screenshot 2024-05-02 202138

I checked all the permissions and language settings on both the A21s and S23 and they are the same. What could be going wrong?

One other thing to mention is the S23 microphone seems to not always work. When I record a video on it it has audio, but when I try to use the microphone function in the Google app it doesn't work while it does on the A21s. Could that potentially be causing the issue.

Platform specs

Aumarka commented 2 months ago

I was able to fix the issue as I had been initialising the SpeechToText to use en-US, which was causing the error above as the default language of the phone was English (Australia). I changed the initialisation to remove the en-US so that it just used the default language and it worked on the S23 (although I still got error code 6 as the microphone of the device still didn't work). Weirdly even when the SpeechToText was set to en-US, it still worked on the A21s even though that device also only had en-AUS installed.

yasirkula commented 2 months ago

I was receiving error code 12 on a single test device and I was also passing en-US so it's good to know that there's a potential solution to that.

I don't remember encountering the issue with error code 6 myself though. Does this solution apply to you: https://stackoverflow.com/a/31424794. I also wonder if, in the background, the speech recognizer keeps running (meaning if I were to ignore that error, whether or not that would just work). That's the annoying thing about Android ecosystem, it's too unreliable, no matter which Android feature you're trying to use (camera, gallery, sharing, speech recognition). There are always numerous undocumented issues to deal with and the code will be riddled with ugly fixes to those edge cases in no time. I'm also an Android user but boy do I love the stability of iOS SDKs when compared to Android SDKs.

I'll rebuild the AAR with more native logs to help test the "if the speech recognizer keeps running in the background" scenario.

yasirkula commented 2 months ago

Could you replace SpeechToText.aar with the one inside this zip archive and check logcat logs starting with "Speech recognition"? All of these logs will have "Unity" tag.

fixiabis commented 1 month ago

I solve this error code after changing option preferOfflineRecognition to true, hope this information will help.

yasirkula commented 1 month ago

I have mixed feelings about this solution 😅 Thank you for sharing it!