Is there any way to use python script in react native app? - python

In my case I want to use Vosk in python for offline speech recognition and want to develope complete application on react native for handeling rest of the operation for controlling my phone. And this should be completely offline so don't want to setup saperate python server.

You can check their example of Android integration https://alphacephei.com/vosk/android and if you want to create a wrapper for React Native. Also, they have a wrapper for Native Script and you can check how they use it for android, for example here is a list of dependencies https://github.com/alphacep/nativescript-vosk/blob/master/src/platforms/android/include.gradle
UPDATE:
just found that react native vosk wrapper already exists: https://github.com/riderodd/react-native-vosk

Related

create android, iOS libraries from python, including dependencies

We working on a project which involves ML/AI integration to the native mobile application. We are programing our ML/AI code in python. Python code has dependencies, that we need to include in our mobile application.
We have tried with kivy but they only create .apk files and apk files can't be called from other apks. So, we need to create libraries that can be included in the android and ios projects.
Also, we tried chequopy but that doesn't support mediapipe which is in heart of our implementation.
Any guidance in that direction will go long way for us.
If your app was entirely self-contained in python including dependencies using recipes should be possible. If rewriting the native app is not an option maybe one idea is to serve the ML over an HTTP API running on a local server (eg flask). Quite cumbersome as users would need to install two apps

Is it possible to write python code inside Flutter using Android Studio?

I'm working on Flutter project in Android Studio platform and I faced a problem with how to write and run python API code inside my Flutter project without letting it as a backend code in another platform? since when I run my Flutter project that connected with python API code in another platform as a backend using post method, it's worked with the emulator but it does not work with my physical android device.
So is there any recommend solution for either the first problem or the second.
Thanks.
No it's not possible to write python code Inside Flutter code
But you can write your api in different framework like Django ,mongodb and use it in your Flutter app

How to intregrate python with java Android studio?

Let's say I have already done algorithms written in python, and now I want to use these algorithms in my android code. Can I use Java to get output from python? I need to send values from EditText as a parameter to python to be calculated in the algorithm and get a result. I can use Android Studio only with Java. Any suggestions?
Make a web API using python web framework like Django, Flask
Then send request to that API endpoint and calculate with your algorithm and return your result.
You can use Retrofit in Android studio to get the result.
Android studio doesn't have native support for python but you could try integrating a web API of python

How to use Firebase with a linux based client app for bidirectional messages communication with server

I've seen Google's documentation and a lot of examples over the internet about how to use Firebase within Android / iOS applications, but I want to develop a client Firebase application which runs on a linux machine.
My requirements are:
Client runs on linux environment (either writtern in C++ or python).
Server is written in Javascript (NodeJS).
Server and client should have bi-directional communication between them using firebase realtime database.
I've seen also the firebase REST api, but I assume that is not good enough for me since I haven't seen a client listener api that listens on a something like onValueChanged.
Question:
How can I implement a linux-based app in C++ or python that listens to messages from server (data changes) using a listener, without having to call some get function each and every few seconds (just like NodeJS have the ref.on("child_changed",...) or ref.on("value",...)?
Help is much appreciated!
Unfortunately there is not official library for Realtime Database in Python but there are some third party wrappers around REST API.
Specifically I would look at Pyrebase library which also supports listening to live changes https://github.com/thisbejim/Pyrebase#streaming
For more information, libraries or other languages look at this page https://firebase.google.com/docs/database/rest/start
Google offers a C++ SDK you can download it here.
There is also a tutorial on the bottom of the page, but if you really want to dig into some code, here is the quickstart code on github from google with examples for each category on Firebase.
Google has also implemented a Game for demonstration purposes in C++ for Desktop OSs. here There you can find more advanced features and code samples.
I have only tried it with an XCode project on Mac OS X, and it works fine. I have no code for real time database but you should find the sample project in the github repo. https://github.com/firebase/quickstart-cpp
I hope this helps!
Greetings.
Haven't you try to use a Realtime Database triggers for C++ (that's is currently on beta) that allows you to simulate the same workflow as on JS?
From my point of view, it is the best way to get it to work as you want.
https://firebase.google.com/docs/functions/database-events

Executing Python Scripts in Android

This link says that Android support Python, Lua and BeanShell Scripts, subsequently for Perl too. If it is so, is it possible for developers to write python scripts and call them in their standard Java based android applications?
I remember reading about this awhile back as well.
It's not on the android dev site.
It's a separate project, android-scripting.
Python API:
API Reference
SL4A API Help
I think I have read somewhere that ASE with Python was a huge library ( several Mo), and so was completely unpractical for a public application.
But you can still use it for development...

Categories