Running python script on Android local server - android

I need to build a chatbot which does not takes any online support.
I am using:
Python chatterbot to build conversation dialogues.
Android's google offline speech recognition to convert speech to text and vice versa.
I want to train the model on my PC and use the generated database.sqlite3 file on android.
The complete flow of the process is as follows:
Pretrained model generated database.sqlite3 which is placed in android.
Voice -> Text -> Local Android Server which runs python script using database.sqlite3 and generates response(text) -> Text to Voice
Now I have the problem of running Python on Android with all the environment needed to run the script on android. Kindly help me out with this.
I have searched stuffs and found setting local server on android using NanoHTTPD/AndroidSync. Now I want to use this server to run python script
If you have any better alternative to any of the steps above, kindly suggest.

In my experience, trying to get Python running on Android doesn't sound like the best way to accomplish this. I'd recommend splitting your project up into two parts:
1. A web application hosted somewhere
You can create a regular web application using a Python framework like Django or Flask. This application can provide a RESTful API that allows other applications to exchange information with your chat bot.
ChatterBot has built-in support for Django and there are numerous examples of the two being used together available. You can also take a look at the "How do I deploy my chat bot to the web?" section for a brief overview and some tips on how to get started.
2. The Android app
The app can access Android's native speech recognition technologies to interpret verbal information before it sends the recognized text to your chat bot API server.

Related

Can I use Google Mobile Vision API in PyCharm?

I am exploring the APIs provided by Google. Firstly, I was experimenting with Google Cloud Vision API with Python in PyCharm in order to try to perform Optical Character Recognition with various texts.
So I wrote a basic program in Python in PyCharm which was calling this API, I gave to it as an input an image which included text e.g. the image/photo of an ice-cream bucket and then takes the text written on this bucket as an output.
Now I want to test the barcode scanner of Google Mobile Vision API. So ideally I would like to call the Google Mobile Vision API in a python program in PyCharm which calls this API, give as an input an image/photo of a barcode and take as an output the details saved in this barcode.
My question is if this can be (easily) done with PyCharm or if I should download Android Studio to do this simple task?
In other words, can I call easily a mobile API in an IDE which is not for mobile app development like Android Studio but in an IDE for desktop applications like Pycharm?
It may be a very basic question but I do not know if I missing something important.
The mobile vision API is designed only for Android and iOS. As far as I know, Pycharm does not work well with Java, so I would say that you would have to create an Android/iOS project in order to test it (It would be a lot harder trying to make it work with python than simply installing Android studio and cloning a mock project).

embedding python program on a web server and connecting to it through Mobile App

I am currently working on an app for android devices. However, the application is too big to build for the device. Therefore, i want to build the core of the application (the part that does most of the work) and place it on a server, and build the light weight part of the application for the mobile device. The App on the android device is to connect to the application on the server, and collect the processed information. I want to build the application that is to run on a server with the Python language, as the application I'm working on does a lot of numeric crunching. Is this possible? If so, how can i embed my Python script to a web server and how to link it to my application
On the server side I would suggest looking the Flask framework (you may find the Flask-Restful framework and having the mobile app accessing it via a REST API. This may be useful depending on your Android experience: http://developer.android.com/training/volley/simple.html However, if you are doing a lot of number crunching, you may need to use WebSockets to connect the two and run your processing in a background thread. In which case I would look at http://www.elabs.se/blog/66-using-websockets-in-native-ios-and-android-apps and https://flask-socketio.readthedocs.org/

Using OpenCV in Parse Cloud Code

This will be my new post if I go wrong please don't judge me hard :)
I'm developing an OpenCV project with Python and also I'm developing its mobile interface in Android. My purpose is to compare plant pictures and decide their species.Researchers who use Android application will take plant photos and upload them (such as 'tree leaf photo'). I intent to execute comparison algorithms in the cloud. I use Parse as mobile database so I thought that I could use Cloud Code in Parse to run my Python codes. Can I do this ?
You can have Parse Cloud Code call out to your Python code using HTTP if you want. Just as you can do the same from the Android app. This code can tell the web hook what images to download and process based on some condition (such as a researcher has uploaded a photo to be processed). Purely up to you how you trigger this. Your Cloud Code is JavaScript only though, same as your Android app is Java only (usually, unless you use Xamarin with C# or something else of course).
No. JavaScript is the only language currently supported for writing CloudCode.

Use AppRTC with a custom server

I've successfully build the AppRTC for android and I'm able to make videocalls providing the address of the demo app ( https://apprtc.appspot.com/?r=XXXXXXXX )
My question is, how can I make this app work with a custom WebRTC server OR with another WebRTC app ( e.g. https://talky.io/)
I'm a little bit confused about how to achieve this.
I've also followed the tutorials HERE and I'm able to make calls between desktop browser but I have no idea how to connect from the android app.
P.S.
If someone is interested I've built the app following the following links:
WebRTC : ninja build not working (see the comments)
http://simonguest.com/2013/08/06/building-a-webrtc-client-for-android/
You can achieve webrtc with your own server.
Several steps to follow:
1.Build your own HTTP server to provide the html service(i.e. the main page of your webRTC project instead of apprtc main page). In this step I use node.js and node-static(https://github.com/cloudhead/node-static).
2.Build your own signalling server. PeerJS is a good choice. Read the doc files. Also, code you HTML file to support peerjs.
Here is an example of peerjs implementation. It helped me a lot
https://developer.mozilla.org/en-US/demos/detail/peerjs
Goodluck!
Actually you can deploy web version of https://apprtc.appspot.com/ to your own server.
It's written on GAE (Google App Engine) - http://webrtc.googlecode.com/svn/trunk/samples/js/apprtc/
This has been moved to branches folder http://webrtc.googlecode.com/svn/branches/3.53/samples/js/apprtc/
Just register GAE account https://appengine.google.com/ and deploy this web app to it.
Next - you can connect WebRTC Android sample to you own GAE server - https://code.google.com/p/webrtc/source/browse/trunk/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
Find line
roomInput.setText("https://apprtc.appspot.com/?r=");
and replace apprtc server name

Making android app work with a python web server

I have a small android application made in eclipse.
Now i need to build a web server with python so they could work together.
Should i make a new python projekt then in some way link it to my application?
Or
Should i use jython and rebuild the app in a jython project?
I have used Visual studio before, and eclipse is not my hometown, så i would really appreciate clear answers.
You don't seem to have a clue about how the android app and the web app are supposed to work together...
You can (theoretically) use just any language and techno you find appropriate for the web app since the communication between the android app and the web app will be http requests / responses.
Also, you can use whatever code editor you want to write Python code, as long as it (the code editor) supports Python.
You can use Kivy to write Python apps that work on Android (as well as just about any other system). Python, they say, has a built in module that you can easily make a web server with. I'm about to try it, I believe.
See
* kivy.org
* http://m.linuxjournal.com/content/tech-tip-really-simple-http-server-python

Categories

Resources