Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions submissions/Terminal_Talks/install.sh
Original file line number Diff line number Diff line change
@@ -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
80 changes: 80 additions & 0 deletions submissions/Terminal_Talks/readme.md
Original file line number Diff line number Diff line change
@@ -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!
12 changes: 12 additions & 0 deletions submissions/Terminal_Talks/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions submissions/Terminal_Talks/scripts/matrix.sh
Original file line number Diff line number Diff line change
@@ -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
113 changes: 113 additions & 0 deletions submissions/Terminal_Talks/terminal-talks
Original file line number Diff line number Diff line change
@@ -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()
7 changes: 7 additions & 0 deletions submissions/Terminal_Talks/themes/dark.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions submissions/Terminal_Talks/themes/hacker.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions submissions/Terminal_Talks/themes/light.sh
Original file line number Diff line number Diff line change
@@ -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