- Posted on
- • Artificial Intelligence
Weekend Artificial Intelligence Linux Projects
- Author
-
-
- User
- linuxbash
- Posts by this author
- Posts by this author
-
Weekend Artificial Intelligence Linux Projects (Bash-Friendly)
Got a weekend and a terminal? You’ve got enough to build real, local AI tools. No cloud lock-in, no API keys, and you keep your data on your machine. In this post, you’ll ship 3–4 practical AI projects entirely on Linux, all scriptable from Bash, with copy-pastable install commands for apt, dnf, and zypper.
What you’ll get:
Real value: transcribe audio, chat with a local model, search your notes semantically, and auto-remove image backgrounds.
Reproducible builds: no vendor dependencies, just open-source tools.
Automation-ready: everything runs from the command line, easily cron/systemd/shell-scripted.
Why local AI on Linux?
Privacy: your audio, notes, and images never leave your disk.
Predictable costs: no API fees.
Speed: no network latency; leverage your CPU/GPU.
Scriptability: compose tools in Bash pipelines, connect to cron, or tie into your existing CLI workflow.
Project 1: Command-line Audio Transcription (whisper.cpp)
Turn podcasts/meetings/voice notes into searchable text using OpenAI’s Whisper model running locally via whisper.cpp—fast, simple, and accurate.
Install prerequisites
Debian/Ubuntu (apt):
sudo apt update
sudo apt install -y build-essential cmake git wget curl ffmpeg libopenblas-dev
Fedora (dnf):
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y cmake git wget curl openblas-devel
# Optional (FFmpeg; typically requires RPM Fusion on Fedora):
# sudo dnf install -y \
# https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
# sudo dnf install -y ffmpeg
openSUSE (zypper):
sudo zypper install -y gcc gcc-c++ make cmake git wget curl openblas-devel ffmpeg
# Note: if ffmpeg is missing codecs, consider the Packman repo for full support.
Build whisper.cpp and download a model
git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp
make -j
bash ./models/download-ggml-model.sh base.en
This grabs a small English-only model. For multilingual audio, try small or medium models (bigger but more accurate).
Transcribe an audio file
# If your audio isn't WAV, convert it (requires ffmpeg):
ffmpeg -i input.mp3 -ar 16000 -ac 1 input.wav
# Run transcription (outputs SRT subtitles and TXT):
./main -m models/ggml-base.en.bin -f input.wav -osrt -of transcript
Optional: a tiny Bash wrapper
cat > ~/bin/transcribe.sh <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <audiofile>" >&2
exit 1
fi
in="$1"
stem="${in%.*}"
tmpwav="$stem.wav"
if [[ "${in##*.}" != "wav" ]]; then
ffmpeg -y -i "$in" -ar 16000 -ac 1 "$tmpwav"
else
tmpwav="$in"
fi
exec ./whisper.cpp/main -m ./whisper.cpp/models/ggml-base.en.bin -f "$tmpwav" -osrt -of "$stem"
EOF
chmod +x ~/bin/transcribe.sh
Now:
transcribe.sh meeting.m4a
Project 2: Terminal Chatbot with a Local LLM (llama.cpp)
Run a small chat model locally using llama.cpp. Great for quick Q&A, drafting, or code suggestions—right in your shell.
Install prerequisites
Debian/Ubuntu (apt):
sudo apt update
sudo apt install -y build-essential cmake git wget curl libopenblas-dev
Fedora (dnf):
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y cmake git wget curl openblas-devel
openSUSE (zypper):
sudo zypper install -y gcc gcc-c++ make cmake git wget curl openblas-devel
Python and pip (for model downloads with the Hugging Face CLI):
Debian/Ubuntu:
sudo apt install -y python3 python3-pip
Fedora:
sudo dnf install -y python3 python3-pip
openSUSE:
sudo zypper install -y python3 python3-pip
Build llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make -j LLAMA_BLAS=1
Download a small instruct-tuned model
We’ll use the Hugging Face CLI to fetch a compact chat model (TinyLlama).
python3 -m pip install --user -U "huggingface_hub[cli]"
# Example: TinyLlama 1.1B Chat (q4_0 quantized)
huggingface-cli download TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF --include "*q4_0.gguf" --local-dir models/tinyllama
Note: You may choose other open instruct models in GGUF format. Smaller models run on most laptops; larger ones need more RAM/VRAM.
Chat in your terminal
cd llama.cpp
./main -m ../models/tinyllama/*q4_0.gguf -i -c 2048 -p "You are a concise Linux terminal assistant."
-i= interactive-c 2048= context window sizeHit Ctrl+C to stop generation, then type.
Optional: quick Bash wrapper
cat > ~/bin/termchat <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
MODEL="${MODEL:-$HOME/models/tinyllama/*q4_0.gguf}"
PROMPT="${PROMPT:-You are a concise Linux terminal assistant.}"
exec $HOME/llama.cpp/main -m "$MODEL" -i -c "${CTX:-2048}" -p "$PROMPT"
EOF
chmod +x ~/bin/termchat
Run:
MODEL="$HOME/models/tinyllama/*q4_0.gguf" termchat
Project 3: Semantic Search for Your Notes (sentence-transformers)
Grepping text finds exact words; embeddings let you find meaning. You’ll index your notes and query by intent (e.g., “renew SSH keys” finds your note “rotate ED25519 keys”).
Install Python and packages
Debian/Ubuntu:
sudo apt update
sudo apt install -y python3 python3-pip
python3 -m pip install --user -U sentence-transformers numpy
Fedora:
sudo dnf install -y python3 python3-pip
python3 -m pip install --user -U sentence-transformers numpy
openSUSE:
sudo zypper install -y python3 python3-pip
python3 -m pip install --user -U sentence-transformers numpy
Note: The first run will download a small embedding model (~90 MB). CPU is fine.
Index your notes
Save as index_notes.py:
#!/usr/bin/env python3
import sys, pathlib, json
from sentence_transformers import SentenceTransformer
import numpy as np
def read_docs(root):
root = pathlib.Path(root).expanduser().resolve()
exts = {".md", ".txt", ".org"}
files = [p for p in root.rglob("*") if p.suffix.lower() in exts]
docs, meta = [], []
for p in files:
try:
text = p.read_text(encoding="utf-8", errors="ignore")
if text.strip():
docs.append(text)
meta.append({"path": str(p), "title": text.splitlines()[0][:120] if text else ""})
except Exception:
pass
return docs, meta
def main():
if len(sys.argv) < 3:
print("Usage: index_notes.py <notes_dir> <out_dir>", file=sys.stderr)
sys.exit(1)
notes_dir, out_dir = sys.argv[1], pathlib.Path(sys.argv[2]).expanduser().resolve()
out_dir.mkdir(parents=True, exist_ok=True)
docs, meta = read_docs(notes_dir)
print(f"Indexing {len(docs)} documents...")
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
emb = model.encode(docs, batch_size=64, convert_to_numpy=True, show_progress_bar=True, normalize_embeddings=True)
np.save(out_dir / "embeddings.npy", emb.astype("float32"))
(out_dir / "meta.json").write_text(json.dumps(meta, ensure_ascii=False, indent=2))
print("Done:", out_dir)
if __name__ == "__main__":
main()
Index your notes directory:
python3 index_notes.py ~/Notes ~/.noteindex
Query by meaning
Save as query_notes.py:
#!/usr/bin/env python3
import sys, json, numpy as np
from sentence_transformers import SentenceTransformer
def main():
if len(sys.argv) < 3:
print("Usage: query_notes.py <index_dir> <query> [k]", file=sys.stderr)
sys.exit(1)
idx_dir, query = sys.argv[1], sys.argv[2]
k = int(sys.argv[3]) if len(sys.argv) > 3 else 5
emb = np.load(f"{idx_dir}/embeddings.npy")
meta = json.load(open(f"{idx_dir}/meta.json", "r", encoding="utf-8"))
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
q = model.encode([query], convert_to_numpy=True, normalize_embeddings=True)[0]
sims = emb @ q # cosine sims (normalized vectors)
top = sims.argsort()[-k:][::-1]
for i in top:
print(f"{sims[i]:.3f} {meta[i]['path']} {meta[i]['title']}")
if __name__ == "__main__":
main()
Run:
python3 query_notes.py ~/.noteindex "how to rotate ssh keys" 7
Optional: Bash aliases
echo 'notes-index() { python3 ~/index_notes.py "${1:-$HOME/Notes}" "$HOME/.noteindex"; }' >> ~/.bashrc
echo 'notes-query() { python3 ~/query_notes.py "$HOME/.noteindex" "$*"; }' >> ~/.bashrc
source ~/.bashrc
Project 4: Batch Remove Image Backgrounds (rembg + ONNX Runtime)
Great for product photos, thumbnails, or slides. This uses a pre-trained segmentation model via rembg, fully offline after install.
Install Python and rembg
Debian/Ubuntu:
sudo apt update
sudo apt install -y python3 python3-pip
python3 -m pip install --user -U rembg
Fedora:
sudo dnf install -y python3 python3-pip
python3 -m pip install --user -U rembg
openSUSE:
sudo zypper install -y python3 python3-pip
python3 -m pip install --user -U rembg
Remove backgrounds
Single image:
rembg p input.png output.png
Whole directory:
rembg i ./input_images ./output_images
Simple Bash loop:
mkdir -p out
for f in *.png *.jpg *.jpeg; do
[ -e "$f" ] || continue
rembg p "$f" "out/${f%.*}_nobg.png"
done
Tips for a smoother weekend
Hardware: CPU works for all projects; BLAS/OpenBLAS accelerates LLMs. If you have a GPU, both whisper.cpp and llama.cpp have build flags for CUDA/Metal/OpenCL—check their READMEs.
Data flow: Combine tools. Example: record -> transcribe -> summarize with your local LLM -> append to your notes -> re-index.
Version pinning: For Python tools, save a
requirements.txtfor reproducibility. For C/C++, tag the repo at a known-good commit.
Call To Action
Pick one project and ship it today:
If you have audio lying around, start with whisper.cpp.
If you want a local assistant, build llama.cpp + TinyLlama.
If your notes are chaos, index them with embeddings.
If you make visuals, batch-remove image backgrounds.
Then: 1) Wrap your commands in scripts under ~/bin. 2) Automate with cron or systemd timers. 3) Share your one-liner or script gist with the community.
Got stuck or want a GPU-accelerated variant? Ask me what hardware you have and I’ll tailor the build flags and model sizes.