OpenInterpreter / 01

The #1 open-source voice interface for desktop, mobile, and ESP32 chips.
https://01.openinterpreter.com/
GNU Affero General Public License v3.0
4.91k stars 516 forks source link

Create an Android APK to run the client on an old android device we do not need #98

Open mysticaltech opened 6 months ago

mysticaltech commented 6 months ago

Is your feature request related to a problem? Please describe. I live far away from the US, and I have an old fully working android phone that I would love to use as an alternative more bulky client for the server.

Describe the solution you'd like A simple APK that runs the app always and does the same thing as the O1 hardware.

Describe alternatives you've considered I do not have time to go down the hardware rabbit hole, and don't want to wait for other batches to ship to Europe.

Additional context My old phone is just waiting for this to make me 100x more productive. So many things I would like to use my voice to do on my computer while working on thinking about stuff, tell it to load my dev env for a particular project, check if pods are running correctly on a particular kube cluster, or read my emails. My phone will stay plugged and on my desk, it will be my full time assistant and coworker, and what a great circular-economy like thing with the useful re-purposing of an old device.

IMG_202403
22_005436_HDR

Lastly, APKs are super easy to install, no need for app stores.

This will also open-up the project to all the poor people in the third world who will never be able to afford to buy or build the device. Having lived in Africa, I know all too well how important that is for many young people there. This is huge IMHO!

mysticaltech commented 6 months ago

Something to get started running python from inside an Android app

Running Python inside an Android app can be achieved through several methods, each with its unique implementation approach. The choice of method depends on your specific requirements, such as the level of Python integration needed, performance considerations, and the complexity of the Python code you intend to run. Here are a few approaches:

1. Using Pydroid 3 or Similar Apps

Pydroid 3 is a Python 3 IDE for Android that can be used to run Python scripts on Android devices. While this is more of an educational or development tool rather than a method for integrating Python into an Android app, it can be useful for testing Python code on Android.

2. Using Chaquopy:

Chaquopy is a plugin for Android Studio that enables you to include Python code as part of your Android app. Here's how you can use it:

  1. Setting up Chaquopy in Android Studio:

    • Add Chaquopy to your project by adding its Maven repository and plugin to your build.gradle files.
    • Enable Python support by adding the appropriate plugin and dependencies configurations.
  2. Adding Python Files:

    • Place your Python files in the src/main/python directory of your project.
  3. Accessing Python Code from Java/Kotlin:

    • Use the Python API provided by Chaquopy to call Python functions from Java or Kotlin. This involves initializing the Python instance and calling your Python functions.

3. Using Kivy or BeeWare:

4. SL4A (Scripting Layer for Android):

SL4A (no longer actively developed but still available) allowed for running various scripting languages, including Python, on Android. It provided a simplified Android API for calling Android functions from scripts. However, its capabilities are limited compared to native app development.

5. Using Termux:

Termux is a terminal emulator for Android, which allows you to run a Linux environment directly on your Android device. You can install Python through Termux and run Python scripts. However, this is not the same as integrating Python into an Android app; it's more about running scripts independently.

Example: Chaquopy Setup

Here is an example of how you might set up Chaquopy in your build.gradle (Module):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        chaquopyVersion = '9.1.0'  // Change to the latest version
    }
    repositories {
        google()
        mavenCentral()
        maven { url "https://chaquo.com/maven" }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.2" // Use the correct Gradle version
        classpath "com.chaquo.python:gradle:$chaquopyVersion"
        // NOTE: Ensure you use the correct version of Chaquopy and other tools.
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url "https://chaquo.com/maven" }
    }
}

And in your build.gradle (App):

apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'

android {
    // configuration settings like compileSdkVersion, etc.
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.chaquo.python:android:9.1.0" // Use the correct Chaquopy version
}

python {
    // Python version and other settings
    buildPython "3.8.10" // Use the correct Python version
}

This setup is just the beginning. You would need to follow the documentation specific to the tool you choose to integrate Python into your Android application fully. Remember that while integrating Python into Android provides powerful capabilities, it can add complexity and increase the size of your application. Consider whether the benefits outweigh these factors for your specific use case.

JIVS commented 6 months ago

Mildly related but are there any android-phone-as-server out there that aren't just an fdroid experiment? 'cause that could serve as a base for this.