python for android crashes at start: modul 'google_speech' and 'gtts' are missing

248 Views Asked by At

I wrote a python3 app called chinese_speaker with kivy and google_speech. after compiling with buildozer, I copied it to my smartphone. Every time I tried to start, it always closed immediately. so I activated adb debugging and in the logfiles I found this lines:

09-22 13:29:50.971 13746 13789 I python  :    File "/home/[user_name]/Documents/Python/Buildozer/chinese_speaker/.buildozer/android/app/main.py", line 10, in <module>
09-22 13:29:50.971 13746 13789 I python  :  ModuleNotFoundError: No module named 'google_speech'
09-22 13:29:50.971 13746 13789 I python  : Python for android ended.

I checked it on my smartphone, but google_speech seems installed:

$ /run/user/1000/gvfs/mtp:host=SAMSUNG_SAMSUNG_Android_R58N146M9KX$ pip3 install google_speech
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: google_speech in /home/[user_name]/.local/lib/python3.8/site-packages (1.1.0)
Requirement already satisfied: appdirs>=1.4.0 in /usr/local/lib/python3.8/dist-packages (from google_speech) (1.4.4)
Requirement already satisfied: requests>=2.6.0 in /usr/lib/python3/dist-packages (from google_speech) (2.22.0)
Requirement already satisfied: web-cache>=1.1.0 in /home/[user_name]/.local/lib/python3.8/site-packages (from google_speech) (1.1.0)

How can I connect my App with the google_speech library?

Thank you very much!

(That's my first post here on Stackoverflow. Please excuse me, if there is some lack of information.

EDIT

I tried the same App without the google_speech library and it worked fine. But if I replace google_speech with gtts, I get the same Error:

09-23 10:47:38.774  5914  5984 I python  :    File "/home/[user_name]/Documents/Python/Buildozer/chinese_speaker/.buildozer/android/app/main.py", line 11, in <module>
09-23 10:47:38.774  5914  5984 I python  :  ModuleNotFoundError: No module named 'gtts'
09-23 10:47:38.774  5914  5984 I python  : Python for android ended.

Do I have to enable this kind of libraries on android, or do I have to specify it in buildozer.spec??

1

There are 1 best solutions below

0
On

As I understood, the problem is, GTTS and google_speech is not working on Android.

For this you can use plyer. But with plyer you can only use the default Text to Speech Language of your android device. So to speak Chinese, you have to change your default text to speech language on your smartphone to Chinese.