File size: 2,656 Bytes
6c46cd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
import subprocess
import requests
from datetime import datetime

# --- CONFIG ---
COLAB_URL = "https://56a0-35-197-74-67.ngrok-free.app/chat"
MODEL_PATH = "/data/data/com.termux/files/home/jarvis/voice/en_US-amy-medium.onnx"
PIPER_BIN = "/data/data/com.termux/files/home/jarvis/voice/bin/piper"
OUT_FILE = "/data/data/com.termux/files/home/jarvis/voice/out.wav"

def speak(text):
    print(f"JARVIS: {text}")
    os.system(f"proot-distro login debian -- {PIPER_BIN} --model {MODEL_PATH} --output_file {OUT_FILE} << 'EOF'\n{text}\nEOF")
    os.system(f"termux-media-player play {OUT_FILE}")

def open_app(app_name):
    """Automatically searches and opens any app on your Realme 7."""
    target = app_name.lower().strip()
    
    # 1. First, check our "Fast List" for common apps
    fast_list = {
        "youtube": "https://www.youtube.com",
        "whatsapp": "whatsapp://send",
        "chrome": "googlechrome://",
        "facebook": "fb://",
        "instagram": "instagram://",
        "calculator": "calc://"
    }
    
    speak(f"Searching for {target}...")

    if target in fast_list:
        os.system(f"termux-open-url {fast_list[target]}")
        return

    # 2. If it's a game (like Free Fire) or something else, search the system
    # This command asks Android to find the best app for the name
    try:
        # This will open the Play Store or the App directly if installed
        os.system(f"termux-open-url intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;component={target};end")
        # Fallback: Just search for it if the intent fails
        os.system(f"termux-open-url https://www.google.com/search?q={target}+android+app+open")
    except:
        speak(f"I couldn't find a path to {target} on this device.")

def listen():
    print("\n[Listening...]")
    try:
        return subprocess.check_output("termux-speech-to-text", shell=True).decode("utf-8").lower().strip()
    except:
        return input("Type command: ").lower().strip()

# --- MAIN LOOP ---
os.system("clear")
speak("Universal app access enabled. Which app should I open, Tamil?")

while True:
    query = listen()
    if not query: continue
    print(f"Tamil: {query}")

    if "open" in query:
        app_to_open = query.replace("open", "").strip()
        open_app(app_to_open)
    elif "exit" in query or "stop" in query:
        speak("Goodbye, Tamil.")
        break
    else:
        try:
            r = requests.post(COLAB_URL, json={"message": query}, timeout=15)
            speak(r.json().get("reply", "Brain is thinking..."))
        except:
            speak("Brain connection lost.")