plyer: Plyer stt not working on my android device

I have build a kivy app to android apk with kivy following the example from this source (https://github.com/kivy/plyer/blob/master/examples/speech2text/main.py)

the app is working good by when I click the button the plyer is not showing any output.

As per the following code https://github.com/kivy/plyer/blob/master/plyer/facades/stt.py “after execute start method you can hear BEEP!” , but I am not able to hear anything even though My device microphone works fine

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

yes, i think adding check_permission/ask_permission code in each android plyer module would make sense, the dev can still ask beforehand if they don’t want users to be asked each permission independently.

@nandamtejas I saw your stack exchange answer https://stackoverflow.com/a/67483202/13714716 you seemed to have got the solution but that doesn’t seem to be working in my case even though I had used same buildozer.spec and .py as in the example (https://github.com/kivy/plyer/blob/master/examples/speech2text/main.py), I also tried giving permissions to my app manually and also using runtime permissions but still it didn’t show anything in the text field. While trying to debug the stt.result showed blank list [] . Can you share your main.py and buildozer.spec so that I can see whether it works in my case or not…

Now I got the answer whoever has the same problem you can use this repo https://github.com/AM-ash-OR-AM-I/SR/blob/main/main.py that I forked from https://github.com/Abhishek-op/SR basically I added the dialog asking for microphone permission to user…

i started implementing a require_permissions decorator on my side, to transparently request the permissions before calling the actual method if all the permissions haven’t been set already, i still need to test it a bit more, and there are subtleties that could make that route harder to ride than i expected, but i think it can work.

request_permissions() generates Android pause/resume events. Called during Kivy build() this is not an issue. Called during Kivy on_start() the pause occurs during on_start (not an issue) but a Kivy on_resume() is generated at a later time. This is an issue because the app code will see an on_resume() with no prior on_pause(). It is reasonable to expect a pause/resume pair, and is commonly used in setting app state; but this assumption can lead to unexpected behavior in the request_permissions() case.
Here are my original experiments https://github.com/kivy/python-for-android/issues/2309 Given the documentation the issue may be Kivy specific, on_start() quite reasonably inhibiting the generation of an on_pause(). In which case my ‘must be in build()’, should be ‘must not be in on_start()’. I prefer documenting the former.

Separately, multiple calls to request_permissions() can lead to a single dialog with missing approvals, in the one test case I looked at (Xcamera + user specified permission) the missing permissions were automatically approved. That was enough I did not dig deeper. Given the documents, perhaps the issue is overlapping calls. User transparent calls of request_permissions() have the potential to be overlapping and lead to unexpected behavior.

Bottom line: there can be undocumented side effects, testing is required.

Thanks for listening to my 2 cents worth.

yes, i think adding check_permission/ask_permission code in each android plyer module would make sense, the dev can still ask beforehand if they don’t want users to be asked each permission independently.

yes I actually added this small code in my main.py

for android.permissions import request_permissions, Permission

# on kivy app class
def on_start(self):
    request_permissions([Permission.RECORD_AUDIO]) # RECORD_AUDIO is for microphone usage for your android device.