🎓 Free: The AI Reel-to-Lead System, 6 short lessons Start now →
Comment “JARVIS”Also in your DMsfrom @aarunverse.ai

Your Own JARVIS on an Android Phone (No Laptop) with Termux

Everything runs on the phone. Termux gives you a Linux terminal, and Termux:API lets Python use the microphone (speech-to-text), the speaker (text-to-speech), notifications, the torch and the battery.

For the AI brain you have three choices. For full privacy, run a small model on the phone with Ollama, so your prompts never leave the device. Or get a free API key from OpenRouter or Google AI Studio. Never share that key with anyone.

Install Termux and Termux:API from F-Droid, not the Play Store: the Play Store build is outdated and the two apps must come from the same source. Then give Termux:API the microphone permission, which is the step most people forget. Without it JARVIS cannot hear you.

The full jarvis.py is below. Save it in Termux (nano jarvis.py, paste, Ctrl+X, Y), then run python jarvis.py. Add your own voice commands in the COMMANDS list at the bottom.

Get Termux on F-Droid →
Copy · paste · run

Prompts & steps

  1. Install F-Droid from f-droid.org, then install Termux and Termux:API from inside F-Droid (not the Play Store)
  2. Open Termux and run the 3 commands one by one: pkg update -y && pkg upgrade -y · pkg install -y python termux-api · pip install requests
  3. Android Settings › Apps › Termux:API › Permissions › Microphone › Allow (most people forget this)
  4. Pick the AI brain: local (pkg install ollama, ollama serve &, ollama pull llama3.2:1b, export JARVIS_BRAIN=ollama) or a free key: export JARVIS_BRAIN=openrouter OPENROUTER_API_KEY=… or export JARVIS_BRAIN=gemini GEMINI_API_KEY=…
  5. Save the code below as jarvis.py (nano jarvis.py, paste, Ctrl+X, Y)
  6. Run python jarvis.py and say: "JARVIS, kal subah 9 baje yaad dilana"
Prompt 1
#!/data/data/com.termux/files/usr/bin/python
"""JARVIS on Android (Termux + Termux:API).

Setup (in Termux, apps installed from F-Droid):
  pkg update -y && pkg upgrade -y
  pkg install -y python termux-api
  pip install requests
Then give Termux:API the microphone permission and run:  python jarvis.py

Pick the AI brain with environment variables (choose ONE):
  Local (private, offline):  pkg install ollama ; ollama serve &  ; ollama pull llama3.2:1b
                             export JARVIS_BRAIN=ollama
  OpenRouter (free key):     export JARVIS_BRAIN=openrouter OPENROUTER_API_KEY=sk-or-...
  Google AI Studio (free):   export JARVIS_BRAIN=gemini GEMINI_API_KEY=...
Never share your API key with anyone.
"""
import datetime as dt
import json
import os
import re
import subprocess
import threading

import requests

BRAIN = os.environ.get("JARVIS_BRAIN", "ollama")
OLLAMA_MODEL = os.environ.get("OLLAMA_MODEL", "llama3.2:1b")
OPENROUTER_MODEL = os.environ.get("OPENROUTER_MODEL", "openrouter/auto")
GEMINI_MODEL = os.environ.get("GEMINI_MODEL", "gemini-2.5-flash")
SYSTEM = ("You are JARVIS, a helpful voice assistant on an Android phone. "
          "Reply in the same language the user speaks (Hindi, English or Hinglish), in one or two short sentences.")
WAKE = ("jarvis", "जार्विस", "जारविस")


def speak(text):
    print("JARVIS:", text)
    subprocess.run(["termux-tts-speak", text])


def listen():
    out = subprocess.run(["termux-speech-to-text"], capture_output=True, text=True).stdout.strip()
    if out:
        print("You:", out)
    return out


def notify(title, text):
    subprocess.run(["termux-notification", "--title", title, "--content", text, "--priority", "high", "--sound"])


def ask_ai(prompt):
    if BRAIN == "ollama":
        r = requests.post("http://localhost:11434/api/chat", timeout=120, json={
            "model": OLLAMA_MODEL, "stream": False,
            "messages": [{"role": "system", "content": SYSTEM}, {"role": "user", "content": prompt}]})
        return r.json()["message"]["content"].strip()
    if BRAIN == "openrouter":
        r = requests.post("https://openrouter.ai/api/v1/chat/completions", timeout=60,
                          headers={"Authorization": "Bearer " + os.environ["OPENROUTER_API_KEY"]},
                          json={"model": OPENROUTER_MODEL,
                                "messages": [{"role": "system", "content": SYSTEM}, {"role": "user", "content": prompt}]})
        return r.json()["choices"][0]["message"]["content"].strip()
    if BRAIN == "gemini":
        url = f"https://generativelanguage.googleapis.com/v1beta/models/{GEMINI_MODEL}:generateContent"
        r = requests.post(url, timeout=60, headers={"x-goog-api-key": os.environ["GEMINI_API_KEY"]}, json={
            "systemInstruction": {"parts": [{"text": SYSTEM}]},
            "contents": [{"role": "user", "parts": [{"text": prompt}]}]})
        return r.json()["candidates"][0]["content"]["parts"][0]["text"].strip()
    raise SystemExit("Set JARVIS_BRAIN to ollama, openrouter or gemini")


# ---------- built-in commands ----------
def set_reminder(text):
    """'kal subah 9 baje yaad dilana' / 'remind me in 10 minutes to drink water'"""
    now = dt.datetime.now()
    m = re.search(r"(\d+)\s*(minute|min|मिनट)", text, re.I)
    h = re.search(r"(\d{1,2})(?::(\d{2}))?\s*(baje|बजे|am|pm|o'?clock)", text, re.I)
    if m:
        when = now + dt.timedelta(minutes=int(m.group(1)))
    elif h:
        hour, minute = int(h.group(1)), int(h.group(2) or 0)
        if re.search(r"pm|shaam|शाम|raat|रात", text, re.I) and hour < 12:
            hour += 12
        when = now.replace(hour=hour % 24, minute=minute, second=0, microsecond=0)
        if re.search(r"\bkal\b|कल|tomorrow", text, re.I) or when <= now:
            when += dt.timedelta(days=1)
    else:
        return "Boss, time bata dijiye, jaise 9 baje ya 10 minute mein."
    note = text

    def fire():
        notify("JARVIS reminder", note)
        speak("Boss, reminder: " + note)

    threading.Timer((when - now).total_seconds(), fire).start()
    return f"Done boss, reminder set hai: {when.strftime('%d %b, %I:%M %p')}."


def tell_time(_text):
    return "Abhi " + dt.datetime.now().strftime("%I:%M %p") + " baje hain."


def battery(_text):
    b = json.loads(subprocess.run(["termux-battery-status"], capture_output=True, text=True).stdout)
    return f"Battery {b['percentage']} percent hai."


def torch(text):
    on = not re.search(r"off|band|बंद", text, re.I)
    subprocess.run(["termux-torch", "on" if on else "off"])
    return "Torch " + ("on" if on else "off") + " kar diya."


# Add your own: "phrase in the command": function
COMMANDS = {
    "yaad dila": set_reminder, "याद दिला": set_reminder, "remind": set_reminder,
    "time kya": tell_time, "टाइम क्या": tell_time, "what time": tell_time,
    "battery": battery, "बैटरी": battery,
    "torch": torch, "टॉर्च": torch, "flashlight": torch,
}


def handle(text):
    low = text.lower()
    for phrase, fn in COMMANDS.items():
        if phrase in low:
            return fn(text)
    return ask_ai(text)


def main():
    speak("JARVIS online. Boliye boss.")
    while True:
        text = listen()
        if not text:
            continue
        low = text.lower()
        if any(w in low for w in ("bye jarvis", "stop jarvis", "exit")):
            speak("Bye boss.")
            break
        for w in WAKE:  # the wake word is optional
            low = low.replace(w, "")
        try:
            speak(handle(text if low.strip() else "hello"))
        except Exception as e:  # keep listening even if the AI call fails
            print("error:", e)
            speak("Sorry boss, abhi connect nahi ho pa raha.")


if __name__ == "__main__":
    main()
Liked this? Go all the way
GTA 6 Thumbnail Maker: Sketch-to-Thumbnail Skill
Recommended

GTA 6 Thumbnail Maker: Sketch-to-Thumbnail Skill

Give Claude your GTA video and get a click-worthy thumbnail: it finds the hook, draws a layout sketch, renders it as hyper-real GTA 6 key art in your ChatGPT or Gemini, and adds the official logo plus a badge.

  • One skill zip for Claude Code
  • Watches your video and finds the hook
  • Layout sketch to hyper-real render
  • Official GTA VI logo + badge or text
$4.99 $9.99 50% off
See the course →
Free updates

Get this on WhatsApp too

Drop your number and I'll send this link (and every new one) to your WhatsApp.

One AI shortcut a day.

RecommendedGTA 6 Thumbnail Maker: Sketch-to-Thumbnail Skill See course →