Kivy python APK built successfully but app is not opening in Mobile.

5,534 views
Skip to first unread message

Saradhadevi Elaiyaraja

unread,
May 7, 2019, 11:50:46 AM5/7/19
to Kivy users support
Hi,

I am new to both python and kivy. I have created my first kivy python application on conversation. Initially i created the apk file using buildozer. When i installed it in my mobile, it did not open. Then i created the apk file successfully without any error using Kivy complete VM (by ZEN code). Then i installed my apk file in mobile and tried to open. I got the loading text with kivy logo but the app is closed immediately. As there is no error, i am not able to figure out the reason. Could you please help me out on this.

Thanks & Regards,
Saradhadevi. I

Horace Johnson

unread,
May 7, 2019, 12:44:48 PM5/7/19
to Kivy users support

I'm having the same exact issue and decided to make a small apk that starts with just showing a white image on screen.  That worked, so I decided to add a label widget and the crash happened again.  That's not good because widgets are a big part of using kivy.


I up-loaded the test data for apk build.

The last time my apk ran well is when it used pygame for bootstrap on mobile.  In fact, it always ran with sdl2 while on desktop put for some reason, pygame was auto selected for bootstrap on the mobile.  Well pygame has been taking away by the Devs but there's clearly something wrong with SDL2/kivy on mobile.  I've tried using my kivy version of 1.9.0 and I've tried using kivy masters...all with python2.

You can't do this in the spec, python==2.7 because i'll download python3 (hostpython3) for some reason.  If I could install my apk as public, I could then check the logs but even that's not an option because the apk build will fail when private_storage = False is uncommented in the spec file.

SDL2_Test.zip

Horace Johnson

unread,
May 7, 2019, 12:55:30 PM5/7/19
to Kivy users support
I think mod1 is missing from that test data I up-loaded before, so here it is.

mod1.py

alexander...@gmail.com

unread,
May 7, 2019, 2:19:15 PM5/7/19
to Kivy users support

Use adb logcat to get the python traceback, or other error message, about what has gone wrong.
Message has been deleted

Saradhadevi Elaiyaraja

unread,
May 7, 2019, 3:22:20 PM5/7/19
to Kivy users support
Hi Alex, Thanks for your reply. I have attached my log sheet . I dont find any error except logcat command.
mylog.txt.txt

Alexander Taylor

unread,
May 7, 2019, 3:23:26 PM5/7/19
to kivy-...@googlegroups.com

I'm not sure what you ran there, but I don't think it was a correct logcat command. What does `buildozer android logcat` do?

On 07/05/2019 20:22, Saradhadevi Elaiyaraja wrote:
Hi Alex, Thanks for your reply. I have attached my log sheet . I dont find any error except logcat command.
--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/X-tk3rTQ638/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/4f78a1b9-9d03-44bf-b551-b37e804984f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Horace Johnson

unread,
May 7, 2019, 7:06:57 PM5/7/19
to Kivy users support

I had adb logcat running while pushing the apk....  I didn't know how to log what was going on with the apk only, so I had to dig through other output.  The logcat data looks confusing as hell...how can anyone see an error in all that...?

It's in my bug.txt file.

Something's up with SDL2.  Labels don't even show text (sdl2 test apk I uploaded) and my main apk still closes right after the startup image.  Does SDL2 support everything pygame did?



kivy 1.9.0
python 2.7

bug.txt

Horace Johnson

unread,
May 7, 2019, 7:09:06 PM5/7/19
to Kivy users support

That bug.txt is going to be hard to read.  I suggest copying the content and pasting to a new python Idle window.  It becomes readable.

Saradhadevi Elaiyaraja

unread,
May 8, 2019, 3:31:45 AM5/8/19
to Kivy users support
Alex, I have used the command buildozer android debug logcat->mylog.cat to debug and create apk file. 

Saradhadevi Elaiyaraja

unread,
May 8, 2019, 3:36:44 AM5/8/19
to Kivy users support

Alexander Taylor

unread,
May 8, 2019, 2:08:24 PM5/8/19
to kivy-...@googlegroups.com

I don't think you can do this, try just `buildozer android logcat`.

On 08/05/2019 08:31, Saradhadevi Elaiyaraja wrote:
Alex, I have used the command buildozer android debug logcat->mylog.cat to debug and create apk file. 
--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/X-tk3rTQ638/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Alexander Taylor

unread,
May 8, 2019, 2:12:30 PM5/8/19
to kivy-...@googlegroups.com

Errors are found by careful inspection. In cases like this where the app has successfully started, you can look at only the lines containing 'python' to get everything that is likely to be important. I would generally expect to see a normal Python traceback identifying the issue, but your log cuts off right about where that would happen. Are you sure you left it running long enough to see logs from where the app fails?

You say both that labels don't show text and that the apk closes right after the startup image, but if the app crashed during startup you wouldn't expect to see any labels anyway. I'm not sure what you mean here.

SDL2 supports everything pygame did and far more.

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/X-tk3rTQ638/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Saradhadevi Elaiyaraja

unread,
May 8, 2019, 2:26:46 PM5/8/19
to Kivy users support
Alex, If i use the command buildozer android logcat, i got the below log message. It is not creating apk file. 
If i use the command buildozer android debug or buildozer android debug run logcat, then only the apk file is getting created successfully. 

kivy@kivy-complete:~/Leo$ buildozer android logcat
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.18.4 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /usr/local/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool
# Run '/home/kivy/Android/android-sdk-28/platform-tools/adb devices'
# Cwd None
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached

Alexander Taylor

unread,
May 8, 2019, 2:28:22 PM5/8/19
to kivy-...@googlegroups.com

According to that log, adb didn't find any attached devices. Is your device plugged into the computer, and is adb enabled on it?

You don't need the apk file to be recreated if you have already made one with the properties you wanted.

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/X-tk3rTQ638/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Saradhadevi Elaiyaraja

unread,
May 8, 2019, 2:37:42 PM5/8/19
to Kivy users support
yes Alex. I did not connect my device when i run the above command. 
I already have my complete apk file. but it is not getting opened in the mobile. Just the loading text with kivy logo shown and then it is getting closed. 

Alexander Taylor

unread,
May 8, 2019, 2:53:20 PM5/8/19
to kivy-...@googlegroups.com

Follow the instructions at https://kivy.org/doc/stable/guide/android.html#debugging-your-application-on-the-android-platform, in particular note that you must enable adb in your developer options and connect the device to your computer. This will allow adb logcat to access the logs stream from the device.

On 08/05/2019 19:37, Saradhadevi Elaiyaraja wrote:
yes Alex. I did not connect my device when i run the above command. 
I already have my complete apk file. but it is not getting opened in the mobile. Just the loading text with kivy logo shown and then it is getting closed. 

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/X-tk3rTQ638/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Saradhadevi Elaiyaraja

unread,
May 9, 2019, 4:29:54 AM5/9/19
to Kivy users support
Alex, I connected my device and tried this command adb logcat and got some info in the log file. I am not able to understand. I have attached the file. My app name is Leo. Could you please help me out.
log.txt

Saradhadevi Elaiyaraja

unread,
May 9, 2019, 5:22:36 AM5/9/19
to Kivy users support
Alex, I tried with another command buildozer android logcat as you suggested and able to get the log info. In this file, i find that i have an import error on audioop in speech_recognition module. So i tried to install the audioop from https://pypi.org/project/micropython-audioop/#description. It says there is no set_up.py info. Any alternative way to install/import audioop?.

05-09 10:37:25.009 10191 10228 I python  :    File "/home/kivy/Leo/.buildozer/android/app/main.py", line 17, in <module>
05-09 10:37:25.009 10191 10228 I python  :    File "/home/kivy/Leo/.buildozer/android/app/leosrcconv.py", line 21, in <module>
05-09 10:37:25.009 10191 10228 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/site-packages/speech_recognition/__init__.py", line 12, in <module>
05-09 10:37:25.010 10191 10228 I python  :  ImportError: No module named audioop
05-09 10:37:25.042 10191 10228 I python  : Python for android ended.
05-09 10:37:25.046 10191 10191 V PythonActivity: onPause()
05-09 10:37:25.046 10191 10191 V SDL     : onPause()
05-09 10:37:25.046 10191 10191 V SDL     : nativePause()
log1.txt

Robert Flatt

unread,
May 10, 2019, 12:00:46 AM5/10/19
to Kivy users support
Is audioop written in Python? If it is written in C then a lot of extra work may be required.

Saradhadevi Elaiyaraja

unread,
May 11, 2019, 1:27:36 AM5/11/19
to Kivy users support
George, It is written in python. It seems that audioop is stripped for space efficiency when creating package. As Alex suggested, i have included it in the whitelist. and my app is getting loaded in my mobile successfully. Now it fails with the error "cannot import name c_wchar_p " while trying to convert speech to text with espeak. Could you please help me.

05-11 07:18:50.500 23773 23811 I python  :    File "/home/kivy/Leo/.buildozer/android/app/leosrcconv.py", line 158, in speak_Question_01
05-11 07:18:50.501 23773 23811 I python  :    File "/home/kivy/Leo/.buildozer/android/app/leosrcconv.py", line 104, in speakText
05-11 07:18:50.501 23773 23811 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/site-packages/pyttsx3/__init__.py", line 46, in init
05-11 07:18:50.503 23773 23811 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/site-packages/pyttsx3/engine.py", line 52, in __init__
05-11 07:18:50.504 23773 23811 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/site-packages/pyttsx3/driver.py", line 75, in __init__
05-11 07:18:50.506 23773 23811 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/importlib/__init__.py", line 37, in import_module
05-11 07:18:50.508 23773 23811 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/site-packages/pyttsx3/drivers/espeak.py", line 5, in <module>
05-11 07:18:50.509 23773 23811 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/site-packages/pyttsx3/drivers/_espeak.py", line 4, in <module>
05-11 07:18:50.511 23773 23811 I python  :  ImportError: cannot import name c_wchar_p
05-11 07:18:50.621 23773 23811 I python  : Python for android ended.
05-11 07:18:50.627 23773 23773 V PythonActivity: onPause()
05-11 07:18:50.627 23773 23773 V SDL     : onPause()
05-11 07:18:50.628 23773 23773 V SDL     : nativePause()
05-11 07:18:50.629 23773 23773 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 23773 (org.test.leoapp)

Saradhadevi Elaiyaraja

unread,
May 19, 2019, 4:07:04 AM5/19/19
to Kivy users support
Hi,

I have resolved the c type variable error. Now it fails with the error "@OSError: dlopen failed: library "libespeak.so.1" not found". As it is additional library for espeak, i have added it in the buildozer.spec file and it is getting successfully added in the folder armeabi-v7a in my application path /home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/libs/armeabi-v7a/. But it is not getting added into the apk file. So my app fails with error while testing in mobile. I am not sure whether it is getting stripped off. Could you please help me out on this.

Android App execution log file:
05-19 09:23:22.335 11276 11314 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/ctypes/__init__.py", line 434, in LoadLibrary
05-19 09:23:22.336 11276 11314 I python  :    File "/home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/private/lib/python2.7/ctypes/__init__.py", line 356, in __init__
05-19 09:23:22.337 11276 11314 I python  :  OSError: dlopen failed: library "libespeak.so.1" not found

Android Debug log file while building apk.

# Package the application
# Search and copy libs for armeabi-v7a
# Copy /usr/lib/x86_64-linux-gnu/libespeak.so.1 to /home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/libs/armeabi-v7a/libespeak.so.1
# Copy /usr/lib/x86_64-linux-gnu/libespeak.so.1.1.48 to /home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/libs/armeabi-v7a/libespeak.so.1.1.48
# project.properties updated
# Gradle project detected, copy files /home/kivy/Leo/.buildozer/android/platform/build/dists/Leoapp/src/main/java
# Run '/usr/bin/python -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name Leoapp --name Leo --version 0.1 --package org.test.leoapp --android_api 27 --minsdk 21 --private /home/kivy/Leo/.buildozer/android/app --orientation portrait --window --copy-libs --arch armeabi-v7a --color=always --storage-dir="/home/kivy/Leo/.buildozer/android/platform/build"'
# Cwd /home/kivy/Repos/python-for-android/
[INFO]:    Will compile for the following archs: armeabi-v7a

Robert Flatt

unread,
May 19, 2019, 7:52:08 PM5/19/19
to Kivy users support

As I understand it the issue here is that audioop is not pure Python. As shown by the C headers, and .so files.
So to execute on Android the C files must be compiled for ARM, it is not clear to me how this is happening in your case.
Generally PIP doesn't have ARM binaries.

I see you have found a workaround, but it is not clear that this is fully addressing the basic issue.

For Android, building packages that are not pure Python does not happen automatically except for known recipes

"libespeak.so.1" not found". As it is additional library for espeak, i have added it in the buildozer.spec
 
Is it an ARM32 binary?

For a package that is not installed from PIP, this simplest way to add a package is to put it in the project source directory (where main.py is).
Any user defined package is included like this (easy to build a simple test case). And this will override any PIP package with the same name.
You can also copy packages from PIP here.

BUT if the package is NOT pure Python, it will have to be build it for ARM. This may be non trivial.

Saradhadevi Elaiyaraja

unread,
May 20, 2019, 12:42:18 PM5/20/19
to Kivy users support
Thanks Robert for your response. Actually i get this libespeak.so.1 file when i installed the espeak library with the command PIP install espeak and also from sudo apt-get install libespeak1. As i am new to Kivy python, I have no idea about the ARM32 library. Actually i have created the apk with kivy complete VM which stripped off the audioop.so file when creating apk file. So i just add this file in the whitelist. Now should i copy and paste the audioop python file or espeak python file in the main.py file path to create a recipe. 


Alexander Taylor

unread,
May 20, 2019, 1:41:21 PM5/20/19
to kivy-...@googlegroups.com

I haven't followed all the details of what you've been doing, but if you want to use espeak it will need a recipe to build for Android (specifically, to build libespeak.so for Android).

People have done text to speech with Kivy before, I think you can call the Android mechanisms for it. This is probably easier.

On 20/05/2019 17:42, Saradhadevi Elaiyaraja wrote:
Thanks Robert for your response. Actually i get this libespeak.so.1 file when i installed the espeak library with the command PIP install espeak and also from sudo apt-get install libespeak1. As i am new to Kivy python, I have no idea about the ARM32 library. Actually i have created the apk with kivy complete VM which stripped off the audioop.so file when creating apk file. So i just add this file in the whitelist. Now should i copy and paste the audioop python file or espeak python file in the main.py file path to create a recipe. 


--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/X-tk3rTQ638/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Robert Flatt

unread,
May 20, 2019, 4:12:15 PM5/20/19
to Kivy users support

i get this libespeak.so.1 file when i installed the espeak library with the command PIP

This approach is not going to work because of different CPU architectures, to understand more do some study on compiled programming languages vs interpreted programming languages.

To get espeak to work you would need to compile it for Android. I have not tried this but I expect it would be significant work, as it is not listed as a supported platform on the espeak Sourceforge page.

Alexander's suggestion sounds like it would work. In place of espeak use the Android Java Speech API (by using pyjnius). This approach doesn't do any checking at the interface of the two languages, so programming errors give run time crashes rather than error messages. Debugging can be a challenge. If you take this approach take small steps.

On Monday, May 20, 2019 at 7:41:21 AM UTC-10, Alexander Taylor wrote:

I haven't followed all the details of what you've been doing, but if you want to use espeak it will need a recipe to build for Android (specifically, to build libespeak.so for Android).

People have done text to speech with Kivy before, I think you can call the Android mechanisms for it. This is probably easier.

On 20/05/2019 17:42, Saradhadevi Elaiyaraja wrote:
Thanks Robert for your response. Actually i get this libespeak.so.1 file when i installed the espeak library with the command PIP install espeak and also from sudo apt-get install libespeak1. As i am new to Kivy python, I have no idea about the ARM32 library. Actually i have created the apk with kivy complete VM which stripped off the audioop.so file when creating apk file. So i just add this file in the whitelist. Now should i copy and paste the audioop python file or espeak python file in the main.py file path to create a recipe. 


--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/X-tk3rTQ638/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-...@googlegroups.com.
Message has been deleted

Saradhadevi Elaiyaraja

unread,
May 21, 2019, 8:52:03 AM5/21/19
to Kivy users support
Thanks Alex, Robert. As suggested, I tried to use the android tts but end up with the error "python : AttributeError: 'module' object has no attribute 'Android'. I have used the below sample code from google search. I have added pyjnius, android in the buildozer requirement and also installed the pyjnius in the system.

Code:

import android

droid = android.Android()
droid.ttsSpeak("Hello")

When i checked the android.py (file came with python for android package ), it has no class or function in the name of "Android". This python file has information about various ndk and sdk installation. Should i install or add any specific package for using android tts.

Robert Flatt

unread,
May 22, 2019, 12:03:43 AM5/22/19
to Kivy users support
Where did you get this from?
Try reading the pyjnius documentation
Read the whole page for the education.
At the bottom is "using TextToSpeech", no idea if it works (as documented) but this (or something very like it) is your best bet
[in the examples where it says "renpy", replace this with "kivy"]

Saradhadevi Elaiyaraja

unread,
May 28, 2019, 2:17:42 PM5/28/19
to Kivy users support
I resolved my previous error and now I am end up with another error "jnius.jnius.JavaException: No constructor matching your arguments".
Could you please help me out.

My Code:

PythonActivity = autoclass('org.kivy.android.PythonActivity')
TextToSpeech = autoclass('android.speech.tts.TextToSpeech')
tts = TextToSpeech(PythonActivity.mActivity, None)
String = autoclass('java.lang.String')
tts.speak(cast('java.lang.String', String(textToSpeak)), TextToSpeech.QUEUE_FLUSH, None)
time.sleep(0.1)

Error Log:
05-28 19:57:39.527 9730 9776 I python : File "jnius/jnius_export_class.pxi", line 253, in jnius.jnius.JavaClass.__init__ 05-28 19:57:39.528 9730 9776 I python : File "jnius/jnius_export_class.pxi", line 305, in jnius.jnius.JavaClass.call_constructor 05-28 19:57:39.528 9730 9776 I python : jnius.jnius.JavaException: No constructor matching your arguments 05-28 19:57:39.561 640 640 I GRALLOC : shrFd=10,fmt=0x1,intFmt=0x1,btStrd=256,size=4096,pid=640 05-28 19:57:39.561 640 640 I GRALLOC : yuv=2,w=16,h=16,Stride u=0 v=0,offset u=0 v=0 

Robert Flatt

unread,
May 28, 2019, 4:08:55 PM5/28/19
to Kivy users support
One thing to try is commenting lines of code, one at a time (from the end).
This will tell you where the first problem is. 
The answer is probably in the Java or pyjnius documentation.

Saradhadevi Elaiyaraja

unread,
Jun 12, 2019, 9:26:51 AM6/12/19
to Kivy users support
Hi, I have resolved the error in my mobile app (conversation using android tts) and executed it in the mobile.But, there is no sound coming from my mobile app. Could you please help me out on this. Also please share me if you have any sample python code with android tts and stt.

My Code:
========

    def java_SpeakText(textToSpeak, lang='US'):

textToSpeak = ''
print ('Leo: ' + str(textToSpeak))
class pyjnius_SpeakText(PythonJavaClass):

    __javainterfaces__ = [ 'java.util.Locale' ]

    def __init__( self, *args, **kwargs ):
                lang='US'

    def java_tts(self):
lang='US'
textString = '' 

#     """ use the text to speach API to speak text out loud :-) """
     if platform == 'android':
Locale = autoclass('java.util.Locale')
print (Locale.getDefault());
PythonActivity = autoclass('org.kivy.android.PythonActivity')
TextToSpeech = autoclass('android.speech.tts.TextToSpeech')
tts = TextToSpeech(PythonActivity.mActivity, None)
String = autoclass('java.lang.String')

  try:
# Play something in english
if lang is not None:
    if lang in ['CANADA', 'CANADA_FRENCH', 'CHINA', 'CHINESE', 'ENGLISH', 'FRANCE', 'FRENCH', 'GERMAN', 'GERMANY', 'ITALIAN', 'ITALY', 'JAPAN', 'JAPANESE', 'KOREA', 'KOREAN', 'PRC', 'PRIVATE_USE_EXTENSION', 'ROOT', 'SIMPLIFIED_CHINESE', 'TAIWAN', 'TRADITIONAL_CHINESE', 'UK', 'UNICODE_LOCALE_EXTENSION', 'US']:
error_codes={-1:'LANG_MISSING_DATA', -2:'LANG_NOT_SUPPORTED'}
ret=tts.setLanguage(getattr(Locale,lang))
ret=tts.setLanguage(Locale.US)
if ret in error_codes:
print ('Language not supported')
   ret=tts.setLanguage(Locale.getDefault())
    else:
print ('Language not supported')
ret=tts.setLanguage(Locale.getDefault)
tts.speak(textToSpeak, TextToSpeech.QUEUE_FLUSH, None)
time.sleep(0.1) #dirty but avoid implementing TextToSpeech.OnInitListener
for i in range(0,10):
    time.sleep(0.1)
while tts.isSpeaking():
    time.sleep(0.1)
if ret == TextToSpeech.LANG_MISSING_DATA:
    raise Exception("Error: LANG_MISSING_DATA")
return ret

finally:
tts.shutdown()

else:
print ("Test in android OS")

print('You: '),

return textString

a = pyjnius_SpeakText()
textToSpeak = a.java_tts()
Reply all
Reply to author
Forward
0 new messages