Banu007 commited on
Commit
6c46cd0
·
verified ·
1 Parent(s): a046d87

Upload jarvis.py

Browse files
Files changed (1) hide show
  1. jarvis.py +74 -0
jarvis.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ import requests
4
+ from datetime import datetime
5
+
6
+ # --- CONFIG ---
7
+ COLAB_URL = "https://56a0-35-197-74-67.ngrok-free.app/chat"
8
+ MODEL_PATH = "/data/data/com.termux/files/home/jarvis/voice/en_US-amy-medium.onnx"
9
+ PIPER_BIN = "/data/data/com.termux/files/home/jarvis/voice/bin/piper"
10
+ OUT_FILE = "/data/data/com.termux/files/home/jarvis/voice/out.wav"
11
+
12
+ def speak(text):
13
+ print(f"JARVIS: {text}")
14
+ os.system(f"proot-distro login debian -- {PIPER_BIN} --model {MODEL_PATH} --output_file {OUT_FILE} << 'EOF'\n{text}\nEOF")
15
+ os.system(f"termux-media-player play {OUT_FILE}")
16
+
17
+ def open_app(app_name):
18
+ """Automatically searches and opens any app on your Realme 7."""
19
+ target = app_name.lower().strip()
20
+
21
+ # 1. First, check our "Fast List" for common apps
22
+ fast_list = {
23
+ "youtube": "https://www.youtube.com",
24
+ "whatsapp": "whatsapp://send",
25
+ "chrome": "googlechrome://",
26
+ "facebook": "fb://",
27
+ "instagram": "instagram://",
28
+ "calculator": "calc://"
29
+ }
30
+
31
+ speak(f"Searching for {target}...")
32
+
33
+ if target in fast_list:
34
+ os.system(f"termux-open-url {fast_list[target]}")
35
+ return
36
+
37
+ # 2. If it's a game (like Free Fire) or something else, search the system
38
+ # This command asks Android to find the best app for the name
39
+ try:
40
+ # This will open the Play Store or the App directly if installed
41
+ os.system(f"termux-open-url intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;component={target};end")
42
+ # Fallback: Just search for it if the intent fails
43
+ os.system(f"termux-open-url https://www.google.com/search?q={target}+android+app+open")
44
+ except:
45
+ speak(f"I couldn't find a path to {target} on this device.")
46
+
47
+ def listen():
48
+ print("\n[Listening...]")
49
+ try:
50
+ return subprocess.check_output("termux-speech-to-text", shell=True).decode("utf-8").lower().strip()
51
+ except:
52
+ return input("Type command: ").lower().strip()
53
+
54
+ # --- MAIN LOOP ---
55
+ os.system("clear")
56
+ speak("Universal app access enabled. Which app should I open, Tamil?")
57
+
58
+ while True:
59
+ query = listen()
60
+ if not query: continue
61
+ print(f"Tamil: {query}")
62
+
63
+ if "open" in query:
64
+ app_to_open = query.replace("open", "").strip()
65
+ open_app(app_to_open)
66
+ elif "exit" in query or "stop" in query:
67
+ speak("Goodbye, Tamil.")
68
+ break
69
+ else:
70
+ try:
71
+ r = requests.post(COLAB_URL, json={"message": query}, timeout=15)
72
+ speak(r.json().get("reply", "Brain is thinking..."))
73
+ except:
74
+ speak("Brain connection lost.")