AI Mood-Based Wallpaper Switcher (Windows)

import cv2

import mediapipe as mp

import numpy as np

import ctypes

import os

import time


# ---------------------------------------

# CONFIGURATION

# ---------------------------------------

WALLPAPER_DIR = "wallpapers"

DETECTION_INTERVAL = 5   # seconds between wallpaper changes


MOOD_WALLPAPERS = {

    "happy": "happy.jpg",

    "sad": "sad.jpg",

    "angry": "angry.jpg",

    "neutral": "neutral.jpg"

}


# ---------------------------------------

# Windows Wallpaper Setter

# ---------------------------------------

def set_wallpaper(image_path):

    ctypes.windll.user32.SystemParametersInfoW(

        20, 0, image_path, 3

    )


# ---------------------------------------

# Face & Landmark Setup

# ---------------------------------------

mp_face_mesh = mp.solutions.face_mesh

face_mesh = mp_face_mesh.FaceMesh(refine_landmarks=True)

mp_draw = mp.solutions.drawing_utils


# ---------------------------------------

# Simple Emotion Detection (Rule-Based)

# ---------------------------------------

def detect_emotion(landmarks):

    # Mouth & eyebrow points

    mouth_left = landmarks[61]

    mouth_right = landmarks[291]

    mouth_top = landmarks[13]

    mouth_bottom = landmarks[14]


    left_eyebrow = landmarks[70]

    right_eyebrow = landmarks[300]


    mouth_width = abs(mouth_right.x - mouth_left.x)

    mouth_height = abs(mouth_bottom.y - mouth_top.y)

    eyebrow_height = abs(left_eyebrow.y - right_eyebrow.y)


    # Heuristic rules

    if mouth_height > 0.035 and mouth_width > 0.04:

        return "happy"

    elif mouth_height < 0.015:

        return "sad"

    elif eyebrow_height < 0.01:

        return "angry"

    else:

        return "neutral"


# ---------------------------------------

# MAIN LOOP

# ---------------------------------------

def main():

    cap = cv2.VideoCapture(0)

    last_change = time.time()

    current_mood = None


    print("🎭 Mood-Based Wallpaper Switcher Started")

    print("Press 'Q' to quit.\n")


    while True:

        ret, frame = cap.read()

        if not ret:

            break


        rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

        results = face_mesh.process(rgb)


        if results.multi_face_landmarks:

            landmarks = results.multi_face_landmarks[0].landmark

            mood = detect_emotion(landmarks)


            cv2.putText(

                frame,

                f"Mood: {mood}",

                (30, 50),

                cv2.FONT_HERSHEY_SIMPLEX,

                1,

                (0, 255, 0),

                2

            )


            # Change wallpaper only after interval

            if mood != current_mood and time.time() - last_change > DETECTION_INTERVAL:

                wallpaper_path = os.path.join(WALLPAPER_DIR, MOOD_WALLPAPERS[mood])

                if os.path.exists(wallpaper_path):

                    set_wallpaper(os.path.abspath(wallpaper_path))

                    print(f"🖼️ Wallpaper changed → {mood}")

                    current_mood = mood

                    last_change = time.time()


        cv2.imshow("AI Mood Detector", frame)


        if cv2.waitKey(1) & 0xFF == ord("q"):

            break


    cap.release()

    cv2.destroyAllWindows()


# ---------------------------------------

# RUN

# ---------------------------------------

if __name__ == "__main__":

    main()


Python Audio Noise Cleaner

import librosa

import numpy as np

import noisereduce as nr

import soundfile as sf

import os


# --------------------------------------------------

# CONFIG

# --------------------------------------------------

NOISE_DURATION = 1.0   # seconds used to estimate noise

OUTPUT_SUFFIX = "_cleaned"


# --------------------------------------------------

# Load audio

# --------------------------------------------------

def load_audio(path):

    audio, sr = librosa.load(path, sr=None, mono=True)

    return audio, sr


# --------------------------------------------------

# Noise reduction

# --------------------------------------------------

def reduce_noise(audio, sr, noise_duration=NOISE_DURATION):

    noise_samples = int(noise_duration * sr)

    noise_clip = audio[:noise_samples]


    reduced = nr.reduce_noise(

        y=audio,

        sr=sr,

        y_noise=noise_clip,

        prop_decrease=1.0

    )

    return reduced


# --------------------------------------------------

# Save cleaned audio

# --------------------------------------------------

def save_audio(original_path, audio, sr):

    base, ext = os.path.splitext(original_path)

    output_path = f"{base}{OUTPUT_SUFFIX}.wav"

    sf.write(output_path, audio, sr)

    return output_path


# --------------------------------------------------

# MAIN

# --------------------------------------------------

if __name__ == "__main__":

    input_path = input("Enter audio file path (.wav/.mp3): ").strip()


    if not os.path.exists(input_path):

        print(" File not found.")

        exit()


    print(" Loading audio...")

    audio, sr = load_audio(input_path)


    print(" Reducing background noise...")

    cleaned_audio = reduce_noise(audio, sr)


    output = save_audio(input_path, cleaned_audio, sr)


    print("\n Noise reduction complete!")

    print(f" Cleaned file saved as: {output}")


Offline Barcode & QR Generator

import tkinter as tk

from tkinter import filedialog, messagebox

from PIL import Image, ImageTk

import qrcode

from pyzbar.pyzbar import decode

import os


# ----------------------------------------

# MAIN APP

# ----------------------------------------

class BarcodeQRApp:

    def __init__(self, root):

        self.root = root

        self.root.title("Offline Barcode & QR Suite")

        self.root.geometry("520x520")


        self.build_ui()


    def build_ui(self):

        tk.Label(self.root, text="Barcode & QR Generator / Reader",

                 font=("Arial", 16, "bold")).pack(pady=10)


        self.text_entry = tk.Entry(self.root, width=45)

        self.text_entry.pack(pady=5)

        self.text_entry.insert(0, "Enter text or URL")


        tk.Button(self.root, text="Generate QR Code",

                  command=self.generate_qr).pack(pady=5)


        tk.Button(self.root, text="Read QR / Barcode from Image",

                  command=self.read_code).pack(pady=5)


        self.image_label = tk.Label(self.root)

        self.image_label.pack(pady=10)


        self.result_label = tk.Label(self.root, text="", wraplength=480)

        self.result_label.pack(pady=10)


    # ----------------------------------------

    # Generate QR

    # ----------------------------------------

    def generate_qr(self):

        text = self.text_entry.get().strip()

        if not text:

            messagebox.showerror("Error", "Enter some text!")

            return


        qr = qrcode.make(text)

        file = filedialog.asksaveasfilename(

            defaultextension=".png",

            filetypes=[("PNG Image", "*.png")]

        )


        if file:

            qr.save(file)

            self.display_image(file)

            messagebox.showinfo("Saved", f"QR saved at:\n{file}")


    # ----------------------------------------

    # Read QR / Barcode

    # ----------------------------------------

    def read_code(self):

        file = filedialog.askopenfilename(

            filetypes=[("Image Files", "*.png *.jpg *.jpeg")]

        )


        if not file:

            return


        img = Image.open(file)

        self.display_image(file)


        decoded = decode(img)

        if not decoded:

            self.result_label.config(text=" No QR or Barcode detected.")

            return


        result_text = ""

        for d in decoded:

            result_text += f"""

Type: {d.type}

Data: {d.data.decode('utf-8')}

---------------------

"""


        self.result_label.config(text=result_text)


    # ----------------------------------------

    # Display image

    # ----------------------------------------

    def display_image(self, path):

        img = Image.open(path)

        img.thumbnail((250, 250))

        self.tk_img = ImageTk.PhotoImage(img)

        self.image_label.config(image=self.tk_img)



# ----------------------------------------

# RUN

# ----------------------------------------

if __name__ == "__main__":

    root = tk.Tk()

    app = BarcodeQRApp(root)

    root.mainloop()


Music Playlist Deduplicator

import os

import hashlib

import tkinter as tk

from tkinter import ttk, filedialog, messagebox

from tinytag import TinyTag


SUPPORTED_EXT = (".mp3", ".wav", ".flac", ".m4a")



# --------------------------------------------------

# Helpers

# --------------------------------------------------

def file_hash(path, block_size=65536):

    """Compute SHA256 hash of a file."""

    h = hashlib.sha256()

    with open(path, "rb") as f:

        for block in iter(lambda: f.read(block_size), b""):

            h.update(block)

    return h.hexdigest()



def get_metadata(path):

    """Extract audio metadata."""

    try:

        tag = TinyTag.get(path)

        return {

            "title": (tag.title or "").strip().lower(),

            "artist": (tag.artist or "").strip().lower(),

            "duration": round(tag.duration or 0, 1)

        }

    except Exception:

        return {"title": "", "artist": "", "duration": 0}



# --------------------------------------------------

# Main App

# --------------------------------------------------

class MusicDeduplicator:

    def __init__(self, root):

        self.root = root

        self.root.title("Music Playlist Deduplicator")

        self.root.geometry("900x520")


        self.files = []

        self.duplicates = []


        self.build_ui()


    # ---------------- UI ----------------

    def build_ui(self):

        top = ttk.Frame(self.root)

        top.pack(fill="x", padx=10, pady=10)


        ttk.Button(top, text="Select Music Folder", command=self.select_folder).pack(side="left")

        ttk.Button(top, text="Scan for Duplicates", command=self.scan).pack(side="left", padx=10)


        self.status = ttk.Label(top, text="No folder selected")

        self.status.pack(side="left", padx=10)


        self.tree = ttk.Treeview(

            self.root,

            columns=("method", "file1", "file2"),

            show="headings"

        )

        self.tree.heading("method", text="Duplicate Type")

        self.tree.heading("file1", text="Song A")

        self.tree.heading("file2", text="Song B")


        self.tree.column("method", width=140)

        self.tree.column("file1", width=360)

        self.tree.column("file2", width=360)


        self.tree.pack(fill="both", expand=True, padx=10, pady=10)


    # ---------------- Logic ----------------

    def select_folder(self):

        self.folder = filedialog.askdirectory()

        if self.folder:

            self.status.config(text=self.folder)


    def scan(self):

        if not hasattr(self, "folder"):

            messagebox.showerror("Error", "Select a music folder first!")

            return


        self.tree.delete(*self.tree.get_children())

        self.files = []

        self.duplicates = []


        for root, _, files in os.walk(self.folder):

            for f in files:

                if f.lower().endswith(SUPPORTED_EXT):

                    path = os.path.join(root, f)

                    self.files.append(path)


        self.find_duplicates()

        self.display_results()


    def find_duplicates(self):

        # --- 1. Exact file hash duplicates ---

        hash_map = {}

        for path in self.files:

            try:

                h = file_hash(path)

                if h in hash_map:

                    self.duplicates.append(("Exact File", hash_map[h], path))

                else:

                    hash_map[h] = path

            except Exception:

                pass


        # --- 2. Metadata duplicates ---

        meta_map = {}

        for path in self.files:

            meta = get_metadata(path)

            key = (meta["title"], meta["artist"], meta["duration"])


            if key != ("", "", 0):

                if key in meta_map:

                    self.duplicates.append(("Metadata Match", meta_map[key], path))

                else:

                    meta_map[key] = path


    def display_results(self):

        if not self.duplicates:

            messagebox.showinfo("Result", "No duplicate songs found!")

            return


        for method, f1, f2 in self.duplicates:

            self.tree.insert("", "end", values=(method, f1, f2))


        messagebox.showinfo(

            "Result",

            f"Found {len(self.duplicates)} duplicate pairs."

        )



# --------------------------------------------------

# RUN

# --------------------------------------------------

if __name__ == "__main__":

    root = tk.Tk()

    app = MusicDeduplicator(root)

    root.mainloop()


Smart Directory Visualizer

import os

import sys

import tkinter as tk

from tkinter import ttk, filedialog, messagebox

import subprocess

import platform


# -------------------------------------------------

# Utility: Open files/folders with default app

# -------------------------------------------------

def open_path(path):

    try:

        if platform.system() == "Windows":

            os.startfile(path)

        elif platform.system() == "Darwin":

            subprocess.Popen(["open", path])

        else:

            subprocess.Popen(["xdg-open", path])

    except Exception as e:

        messagebox.showerror("Error", f"Cannot open:\n{e}")


# -------------------------------------------------

# Main App

# -------------------------------------------------

class DirectoryVisualizer:

    def __init__(self, root):

        self.root = root

        self.root.title("Smart Directory Visualizer")

        self.root.geometry("800x500")


        self.create_ui()


    def create_ui(self):

        top = ttk.Frame(self.root)

        top.pack(fill="x", padx=10, pady=10)


        ttk.Button(top, text="Select Folder", command=self.choose_folder).pack(side="left")


        self.path_label = ttk.Label(top, text="No folder selected")

        self.path_label.pack(side="left", padx=10)


        # Treeview

        self.tree = ttk.Treeview(self.root)

        self.tree.pack(fill="both", expand=True, padx=10, pady=10)


        self.tree.heading("#0", text="Folder Structure", anchor="w")


        # Scrollbar

        scrollbar = ttk.Scrollbar(self.tree, orient="vertical", command=self.tree.yview)

        self.tree.configure(yscrollcommand=scrollbar.set)

        scrollbar.pack(side="right", fill="y")


        # Events

        self.tree.bind("<<TreeviewOpen>>", self.on_expand)

        self.tree.bind("<Double-1>", self.on_double_click)


    # -------------------------------------------------

    # Folder selection

    # -------------------------------------------------

    def choose_folder(self):

        folder = filedialog.askdirectory()

        if not folder:

            return


        self.path_label.config(text=folder)

        self.tree.delete(*self.tree.get_children())


        root_node = self.tree.insert("", "end", text=folder, open=False, values=[folder])

        self.tree.set(root_node, "fullpath", folder)

        self.add_dummy(root_node)


    # -------------------------------------------------

    # Lazy loading helpers

    # -------------------------------------------------

    def add_dummy(self, parent):

        self.tree.insert(parent, "end", text="Loading...")


    def on_expand(self, event):

        node = self.tree.focus()

        self.load_children(node)


    def load_children(self, parent):

        fullpath = self.get_fullpath(parent)


        # Remove dummy

        self.tree.delete(*self.tree.get_children(parent))


        try:

            for name in sorted(os.listdir(fullpath)):

                path = os.path.join(fullpath, name)

                node = self.tree.insert(parent, "end", text=name, open=False)

                self.tree.set(node, "fullpath", path)


                if os.path.isdir(path):

                    self.add_dummy(node)

        except PermissionError:

            pass


    def get_fullpath(self, item):

        parent = self.tree.parent(item)

        if parent:

            return os.path.join(self.get_fullpath(parent), self.tree.item(item, "text"))

        else:

            return self.tree.item(item, "text")


    # -------------------------------------------------

    # Open file/folder on double click

    # -------------------------------------------------

    def on_double_click(self, event):

        item = self.tree.focus()

        path = self.get_fullpath(item)

        if os.path.exists(path):

            open_path(path)


# -------------------------------------------------

# RUN

# -------------------------------------------------

if __name__ == "__main__":

    root = tk.Tk()

    app = DirectoryVisualizer(root)

    root.mainloop()