0

I am using kivy to create an android app. I need to install the deepspeech framework, however, in order for deepspeech to be installed it is necessary to create a recipe. I created a recipe and built the apk, there were no errors in the build, it created the apk and also, as far as I could see in the folders, the deepspeech was built. However after I install the app in the phone and try to run the app, it crashes and says there is no module named deepspeech. Does anyone know what i am doing wrong? I've been stuck on this for a while now, and can't seem to find the end of this :/.

from pythonforandroid.recipe import PythonRecipe
from pythonforandroid.toolchain import current_directory, shprint
import sh


class deepspeechRecipe(PythonRecipe):
    version = 'v0.9.2'
    url = 'https://github.com/mozilla/DeepSpeech/archive/{version}.tar.gz'
    depends = ['numpy', 'setuptools']
    call_hostpython_via_targetpython = False
    site_packages_name = 'deepspeech'

    def build_arch(self, arch):
        env = self.get_recipe_env(arch)
        with current_directory(self.get_build_dir(arch.arch)):
            # Build python bindings
            hostpython = sh.Command(self.hostpython_location)
            shprint(hostpython,
                    'setup.py',
                    'build_ext', _env=env)
        # Install python bindings
        super().build_arch(arch)

    def get_recipe_env(self, arch):
        env = super().get_recipe_env(arch)
        numpy_recipe = self.get_recipe('numpy', self.ctx)
        env['CFLAGS'] += ' -I' + numpy_recipe.get_build_dir(arch.arch)
        #env['LDFLAGS'] += ' -L' + sqlite_recipe.get_lib_dir(arch)
        env['LIBS'] = env.get('LIBS', '') + ' -lnumpy'
        return env



recipe = deepspeechRecipe()

Buildozer:1.4.0

requirements = python3==3.7.14, hostpython3==3.7.14, kivy, kivymd, sqlite3, numpy==1.14.5, deepspeech, apsw

If you need any extra information I can add.

I have already tried using tensorflow to run the model, however, the model gives an array as the output and I don't know the right procedures to transform that into a text form. I have already tried other recipes (like opencv) and all work fine.

Edit: I found out that when i use the recipe it does run, and it does build properly, but only the deepspeech_training part because the setup.py only installs that. To install other parts like the model class it is necessary to use another setup.py located in "native_client/python", but that requires the rest of the folders, so I still need to figure that out.

Edit2:I was able to build the packages that i wanted (the inference of deepspeech) however when i run it gives the following error.

python : ImportError: dlopen failed: library "libc++_shared.so" not found: needed by /data/user/0/org.test.myapp/files/app/_python_bundle/site-packages/deepspeech/_impl.so in namespace classloader-namespace python : Python for android ended.

1 Answers1

0

Add pillow in your requirements and check if it works!

requirements = python3==3.7.14, hostpython3==3.7.14, kivy, kivymd, sqlite3, numpy==1.14.5, deepspeech, apsw, pillow

Tom
  • 26
  • 2
  • Thanks for the answer. It still has the same problem (No module named 'deepspeech'). However i found out something interesting. I will give the full update in the main post – Gonçalo Pereira Nov 02 '22 at 09:20
  • @GonçaloPereira, try just putting python3 and hostpython3, instead of giving them specific versions. – Tom Nov 03 '22 at 21:07
  • That was the first test, but it actually needs to be this version otherwise it does not work. However i did get a new update (I am going to update the main post) which it seems to be closer to the end result. – Gonçalo Pereira Nov 04 '22 at 09:06
  • @GonçaloPereira, When you were converting your app to an apk I think you didn't install some of the libraries. – Tom Nov 04 '22 at 17:23