Kaljurand / K6nele

An Android app that offers speech-to-text user interfaces to other apps
http://kaljurand.github.io/K6nele/
Apache License 2.0
267 stars 83 forks source link

android 11 insufficient permissions #82

Closed jim-perkins closed 2 years ago

jim-perkins commented 3 years ago

Hi I am using this app v1.7.40 downloaded from fdroid with my own personal kaldi-gstreamer-server. It worked fine on android 10. with android 11 the app does not ask for any permissions. Even after manually granting permissions I get this error. Insufficient permissions.

https://github.com/Kaljurand/K6nele/blob/f4783aa0572d9cf380eff06cd9620b74eaff71ec/app/src/main/res/values/strings.xml#L224

the device is a pixel 3xl. I tested this with the latest official google firmware and also with grapheneOS ( which does not utilize google play services )

thanks so much for this app it gives me the ability to use Speech to text without using google servers. Let me know how I can help

Kaljurand commented 3 years ago

You are probably encountering the issue described in https://issuetracker.google.com/issues/160395361. I believe that it's a regression in Android 11, but Google seems to disagree (although I'm not sure they carefully read the bug report). In any case, I don't know how to work around this issue within Kõnele itself.

The current solution is to install the server interface as a separate app (e.g. https://github.com/Kaljurand/K6nele-service) and set Kõnele to use that as the recognition provider. This setup is demonstrated in the video https://www.youtube.com/watch?v=VLjV8JulEow (in Estonian).

It's best to use Kõnele v1.7.50 and Kõnele service v0.1.00, available on the Releases pages, although slightly earlier versions should also work.

Kõnele service is currently not available on F-Droid, but as it's more-or-less a subset of Kõnele it could be submitted there as well.

jim-perkins commented 3 years ago

thanks for the quick reply. I can confirm that installing Release versions of the K6nele-service and K6nele resolved the permissions issues with Android 11. Specifically GrapheneOS based on Android 11.

Regarding submitting K6nele-service to fdroid: It isnt a problem installing the service from the release page however I use fdroid to update my FOSS apps. Probably wont update K6nele service again till it quits working :-) I imagine as android 11 becomes mainstream this issue will become more prevalent, although I admit I didnt read the issue on google because it required a google account login.

thanks again for your time and effort on this app and support. I will let you decide whether to close this issue or not,

Kaljurand commented 3 years ago

Glad that you managed to resolve the issue.

Here is a copy of the above-mentioned bug report (https://issuetracker.google.com/issues/160395361), titled [Android 11 DP/Beta] ee.ioc.phon.android.speak fails to access SpeechRecognizer due to lack of permission

2020-07-03. Me:

The app Kõnele (ee.ioc.phon.android.speak) works on Android 10, but does not work on Android 11. I am an Android developer, using build RPB1.200504.020 on Pixel 2.

In order to reproduce the problem:

  1. Install the app (beta version 1.7.30, or the latest stable version 1.6.98)
  2. Launch the app
  3. Press on the yellow microphone button

Expected: a permission requesting dialog should pop up, asking for the microphone permission

Actual: the microphone button turns grey and nothing happens.

When the microphone permission is first assigned via the system dialog ("App info") and then the microphone button is pressed, then a short message briefly appears: "[insufficient permissions]". Expected: the app should start recording (because the permissions have been given).

Some background. When the microphone button is pressed then Kõnele requests a speech recognizer service via the SpeechRecognizer API (https://developer.android.com/reference/android/speech/SpeechRecognizer). It can request any existing service installed on the phone, but it also comes with two services of its own, one of them is requested by default. The described issue does not occur when accessing Google's recognizer services. But it does occur when accessing the Kõnele's own service. (The requested service can be specified in the Kõnele settings.)

So I think there is a regression in the SpeechRecognizer API.

2020-07-10. Google:

This is a issue that the app developer needs to fix. The app assumes once a permission is granted it is always granted. That is not the case. The user might revoke it. App developer should follow the official guide on requesting permissions. This is designed to prevent situations like this.

2020-07-31. Me:

Please reconsider the resolution of this issue. I would like to point out that:

  • an app (specifically ee.ioc.phon.android.speak) that works fine in Android 10 and earlier, does not work anymore on Android 11 (regardless of if it targets v11 or an earlier version). Is this breaking of backwards compatibility really an intended behavior?

  • if the microphone permission has been explicitly granted (e.g. via the system UI, i.e. App info / Permissions) and has NOT been revoked, the recording still fails because of lack of permissions.

Meanwhile I've found that there is no issue if the SpeechRecognizer service implementation is called from a separate app. So a work-around has been to move this implementation from ee.ioc.phon.android.speak into a new app (https://github.com/Kaljurand/K6nele-service; ee.ioc.phon.android.k6neleservice). However, while this approach has some benefits (more modularity), it has also some major downsides (the user has to install 2 apps, and grant the microphone permissions for them separately).

felixwiemuth commented 3 years ago

Hi, I just had the same issue when trying out the app (didn't try the workaround though). Could you mention the limitation and add a link to this issue/workaround in the F-Droid description as well when starting the app on Android 11?

Adding the service app to F-Droid as well would then make sense of course.

Thanks for bringing Open source / service-independent speech recognition to Android!

Kaljurand commented 3 years ago

Yes, there are 3 TODO-items here:

I'll look into the first two items in the coming weeks. The third item is more work.

felixwiemuth commented 3 years ago

Probably F-Droid doesn't support the <a href> tag for descriptions in the app (it seems it does on the website). In the app, a plain URL in the description is rendered as a link. Not sure about the F-Droid website in that case. There is an example where the URL is used as link target and text in <a href>, so that should work in both places.

Maybe you also have to remove the description from the metadata repository so that the one from your metadata folder is used.

  • implement a wizard that runs during the first launch and helps the user set up and configure the dependencies

Maybe instead of a wizard, for the beginning a dialog with the link in case a dependency is missing (on Android 11) is all that is needed :).

Kaljurand commented 3 years ago

Thanks @felixwiemuth ! Regarding the description I've made an attempt to improve the situation:

jim-perkins commented 2 years ago

Hello. my phone was just updated to android 12 and the permissions errors have returned with konele . Please advise if I should open a new issue. Thanks.

OS: grapheneos with android 12 (no google play services ) OS URL : https://grapheneos.org/ Hardware: pixel 3 xl Konele :version 1.7.56 / 1.8 Konele service version :version 0.1.00

I did notice there is a konele version 1.8 but it conflicted with 1.7.56. I uninstalled 1.7.56 and installed 1.8 and still had 'insufficient permissions '

Thanks so much. I enjoy running my own instance of kaldi-gstreamer-server for my text to speech needs.

Kaljurand commented 2 years ago

Hi @jim-perkins, the hope has been that https://github.com/Kaljurand/K6nele/commit/563b25812591572202ec146e42d3e1f1fc901b4c fixes the permission issue, and you don't need anymore a separate app (Kõnele-service) to provide a service. I've verified the fix on Android v11. It's currently been released only on the Google Play beta channel and now also as https://github.com/Kaljurand/K6nele/releases/tag/v1.8.10. Can you try this? You might have to manually (i.e. via the system UI) give the microphone permissions, because sometimes the permission dialog does not pop up (and the Kõnele mic button stays grey). I haven't tested any of this on Android v12 yet, so it would be very helpful if you let me know how it goes.

I think we can continue this thread here, without opening a new issue, unless it's clear that it's v12-specific. The APK-specific comments can be also added to https://github.com/Kaljurand/K6nele/discussions/93.

jim-perkins commented 2 years ago

Thanks so much for your reply and effort.

Yes this latest version , v 1.8 , works on android 12. I uninstalled the k6nele service as it was no longer needed.

I will Close this issue again with this comment. Thanks again

ippocratis commented 7 months ago

Android 13 has this bug Can someone reopen?