diff --git a/submissions/Terminal_Talks/install.sh b/submissions/Terminal_Talks/install.sh new file mode 100755 index 00000000..99366f57 --- /dev/null +++ b/submissions/Terminal_Talks/install.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +echo "šŸ“¦ Installing Terminal Talks..." + +# Install Python dependencies forcefully +echo "šŸ”§ Installing Python dependencies " +python3 -m pip install --user --break-system-packages --force-reinstall -r requirements.txt + +# Define install target +TARGET="$HOME/.local/bin" +CMD_NAME="terminal-talks" + +# Create target directory if needed +mkdir -p "$TARGET" + +# Copy script +if cp terminal-talks "$TARGET/$CMD_NAME"; then + chmod +x "$TARGET/$CMD_NAME" + echo "āœ… Installed to $TARGET/$CMD_NAME" +else + echo "āŒ Failed to copy script to $TARGET" + echo "Please try manually:" + echo " sudo cp terminal-talks /usr/local/bin/$CMD_NAME" + echo " sudo chmod +x /usr/local/bin/$CMD_NAME" + exit 1 +fi + +# Warn if not in PATH +if ! echo "$PATH" | grep -q "$TARGET"; then + echo "" + echo "āš ļø $TARGET is not in your PATH." + echo "Add this line to your ~/.bashrc or ~/.zshrc:" + echo 'export PATH="$HOME/.local/bin:$PATH"' + echo "Then run: source ~/.bashrc" +else + echo "šŸš€ You can now run the tool by typing:" + echo " $CMD_NAME" +fi diff --git a/submissions/Terminal_Talks/readme.md b/submissions/Terminal_Talks/readme.md new file mode 100644 index 00000000..0f960563 --- /dev/null +++ b/submissions/Terminal_Talks/readme.md @@ -0,0 +1,80 @@ +# -------------------------šŸ’»šŸŽ™ļø TerminalTalks šŸŽ™ļøšŸ’» -------------------------- + +TerminalTalks is an **offline, voice-powered command suggestion tool** for Linux. Speak natural phrases like _"list files"_ or _"check IP,"_ and it will suggest the appropriate terminal command like `ls` or `ip a`. Perfect for when you forget commands or want hands-free Linux exploration! + +## ✨ Features +- šŸ›œ **Works completely offline** (no internet required after setup) +- šŸ‡®šŸ‡³ Supports **Indian English accent** using Vosk STT model +- šŸ“‹ Maps speech to **150+ common Linux commands** +- ⚔ **Simple one-command install** script +- šŸ”§ Easy to modify and expand command set +- 🐧 Beginner-friendly, works on most Linux systems +- Supports theme switching + +## šŸ› ļø How It Works +1. Run `terminal-talks` from any terminal +2. It starts listening to your voice šŸŽ¤ +3. Speech is transcribed locally using Vosk +4. Searches for matching command in its dictionary +5. Shows the best Linux command match +6. Copy and run it manually + +**Example:** +šŸŽ¤ You say: _"list all files"_ +šŸ’» It shows: `Suggested command: ls -a` + +## šŸ“„ Installation +> **Note:** Before installing, you must manually download the offline model due to file size. + +### Step 1 — Download Speech Recognition Model +1. Visit: [https://alphacephei.com/vosk/models](https://alphacephei.com/vosk/models) +2. Download: `vosk-model-en-in-0.51` +3. Extract and rename folder to `model` +4. Place in TerminalTalks project directory + +### Step 2 — Run Install Script +```bash +chmod +x install.sh +./install.sh +``` +Step 3 — Use the Tool +```bash +terminal-talks +``` +Try saying: "make a folder" → Shows: Suggested command: mkdir + +## šŸ“š Example Commands + +| You Say | Suggested Command | +|------------------------------|--------------------| +| "list files" | `ls` | +| "show all files" | `ls -a` | +| "make a folder" | `mkdir` | +| "remove a directory" | `rm -r` | +| "check IP address" | `ip a` | +| "what's my current path" | `pwd` | +| "clear the screen" | `clear` | +| "view running processes" | `top` | + +*Over 150 phrases supported!* + +## āš™ļø Requirements + +- Python 3.7+ +- Linux-based system (Ubuntu, Arch, Debian, etc.) +- Working microphone +- ~1 GB free space for model + +## āœ”ļø Tested On + +- Ubuntu 22.04 āœ… +- Arch Linux āœ… +- Debian 12 āœ… +## šŸš€ Built For +This project was built for Hack Club's TerminalCraft šŸ› ļø + +## šŸ“¬ Contact +Created by Sameer Kulhari +GitHub Repository : https://github.com/Sameer-Kulhari/Terminal_Talks + +šŸ’” Pro Tip: Add your own custom commands by editing the mapping dictionary! diff --git a/submissions/Terminal_Talks/requirements.txt b/submissions/Terminal_Talks/requirements.txt new file mode 100644 index 00000000..e4b844c8 --- /dev/null +++ b/submissions/Terminal_Talks/requirements.txt @@ -0,0 +1,12 @@ +certifi==2025.6.15 +cffi==1.17.1 +charset-normalizer==3.4.2 +idna==3.10 +pycparser==2.22 +requests==2.32.4 +sounddevice==0.5.2 +srt==3.5.3 +tqdm==4.67.1 +urllib3==2.5.0 +vosk==0.3.45 +websockets==15.0.1 diff --git a/submissions/Terminal_Talks/scripts/matrix.sh b/submissions/Terminal_Talks/scripts/matrix.sh new file mode 100755 index 00000000..c09e4167 --- /dev/null +++ b/submissions/Terminal_Talks/scripts/matrix.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# scripts/matrix.sh + +echo "šŸ’» Entering Matrix mode..." +echo -e "\e[1;40m" +tr -c "[:alnum:]" "A" < /dev/urandom | head -c 10000 | fold -w 80 | while read line; do + echo -e "\e[32m$line\e[0m" + sleep 0.05 +done diff --git a/submissions/Terminal_Talks/terminal-talks b/submissions/Terminal_Talks/terminal-talks new file mode 100755 index 00000000..465c9b03 --- /dev/null +++ b/submissions/Terminal_Talks/terminal-talks @@ -0,0 +1,113 @@ +#!/usr/bin/env python3 + +import os +import queue +import sounddevice as sd +import vosk +import sys +import subprocess +import json + +# Hide Vosk logging +os.environ["VOSK_LOG_LEVEL"] = "-1" + +# ==== THEME SELECTOR ==== + +def select_theme(): + print("\nšŸŽØ Choose a Terminal Theme:") + print("1. Dark") + print("2. Light") + print("3. Hacker (Matrix-style green)") + + choice = input("Enter your choice (1/2/3): ").strip() + theme_scripts = { + "1": "themes/dark.sh", + "2": "themes/light.sh", + "3": "themes/hacker.sh" + } + + if choice in theme_scripts: + subprocess.run(["bash", theme_scripts[choice]]) + else: + print("āŒ Invalid choice.") + +# ==== MATRIX MODE ==== + +def enter_matrix_mode(): + subprocess.run(["bash", "scripts/matrix.sh"]) + +# ==== SPEECH RECOGNITION ==== + +def get_speech(model): + q = queue.Queue() + + def callback(indata, frames, time, status): + if status: + print(status, file=sys.stderr) + q.put(bytes(indata)) + + with sd.RawInputStream(samplerate=16000, blocksize=8000, dtype='int16', + channels=1, callback=callback): + print("šŸŽ¤ Speak now (press Ctrl+C to stop)...") + rec = vosk.KaldiRecognizer(model, 16000) + + while True: + data = q.get() + if rec.AcceptWaveform(data): + result = json.loads(rec.Result()) + return result.get("text", "") + +# ==== MAN PAGE QUERY ==== + +def query_man_db(query): + try: + result = subprocess.run(["man", "-k", query], capture_output=True, text=True) + lines = result.stdout.strip().split('\n') + + if not lines or lines[0].strip() == "": + return "āŒ No matching commands found in man pages." + + suggestions = ["āœ… Suggestions:"] + for line in lines[:10]: # Limit to top 10 + parts = line.split(" - ", 1) + if len(parts) == 2: + cmd_info = parts[0].strip() + description = parts[1].strip() + suggestions.append(f"- {cmd_info}: {description}") + else: + suggestions.append(f"- {line.strip()}") + return "\n".join(suggestions) + + except Exception as e: + return f"\nāš ļø Error querying man: {e}" + +# ==== MAIN PROGRAM ==== + +def run_main(): + MODEL_PATH = "model" + if not os.path.exists(MODEL_PATH): + print(f"ā— Model not found at: {MODEL_PATH}") + sys.exit(1) + + model = vosk.Model(MODEL_PATH) + try: + text = get_speech(model) + print(f"\nšŸ“ You said: {text}") + print(query_man_db(text)) + except KeyboardInterrupt: + print("\nšŸ‘‹ Exiting.") + +# ==== ENTRY POINT ==== + +if __name__ == "__main__": + if len(sys.argv) > 1: + cmd = sys.argv[1].lower() + if cmd == "theme": + select_theme() + elif cmd == "matrix": + enter_matrix_mode() + else: + print(f"āš ļø Unknown option: {cmd}") + print("Usage: terminal-talks [theme | matrix]") + else: + run_main() diff --git a/submissions/Terminal_Talks/themes/dark.sh b/submissions/Terminal_Talks/themes/dark.sh new file mode 100755 index 00000000..949e5198 --- /dev/null +++ b/submissions/Terminal_Talks/themes/dark.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Dark terminal prompt +echo "Applying Dark Theme..." +sed -i '/# TerminalTalks Theme/d' ~/.bashrc +echo '# TerminalTalks Theme' >> ~/.bashrc +echo 'export PS1="\[\033[0;32m\]\u@\h:\w$ \[\033[0m\]"' >> ~/.bashrc +source ~/.bashrc diff --git a/submissions/Terminal_Talks/themes/hacker.sh b/submissions/Terminal_Talks/themes/hacker.sh new file mode 100755 index 00000000..b22dd33a --- /dev/null +++ b/submissions/Terminal_Talks/themes/hacker.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Hacker green prompt +echo "Applying Hacker Theme..." +sed -i '/# TerminalTalks Theme/d' ~/.bashrc +echo '# TerminalTalks Theme' >> ~/.bashrc +echo 'export PS1="\[\033[1;32m\][HACKER] \u@\h:\w$ \[\033[0m\]"' >> ~/.bashrc +source ~/.bashrc diff --git a/submissions/Terminal_Talks/themes/light.sh b/submissions/Terminal_Talks/themes/light.sh new file mode 100755 index 00000000..5046007d --- /dev/null +++ b/submissions/Terminal_Talks/themes/light.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Light terminal prompt +echo "Applying Light Theme..." +sed -i '/# TerminalTalks Theme/d' ~/.bashrc +echo '# TerminalTalks Theme' >> ~/.bashrc +echo 'export PS1="\[\033[1;34m\]\u@\h:\w$ \[\033[0m\]"' >> ~/.bashrc +source ~/.bashrc