CoolFace
Apppublic

prasad8686/HandGestures

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py35 linesDownload Raw Back to root
1import gradio as gr2from transformers import pipeline3 4# Load AI models5asr = pipeline("automatic-speech-recognition", model="openai/whisper-base")6chatbot = pipeline("text-generation", model="gpt2")7 8# Gesture classifier (dummy for now, replace with real ML model)9def classify_gesture(image):10    # In real project -> use MediaPipe or CNN model11    return "Thumbs Up"  12 13# Voice command handler14def handle_voice(audio):15    text = asr(audio)["text"]16    reply = chatbot(text, max_length=100, num_return_sequences=1)[0]["generated_text"]17    return f"User said: {text}\nAssistant: {reply}"18 19# Gesture handler20def handle_gesture(image):21    gesture = classify_gesture(image)22    actions = {23        "Thumbs Up": "OK! Proceeding...",24        "Thumbs Down": "Cancelled.",25        "Open Hand": "Stopping action.",26    }27    return f"Detected: {gesture}\nAssistant: {actions.get(gesture, 'Unknown gesture')}"28 29# Gradio UI30voice_ui = gr.Interface(fn=handle_voice, inputs=gr.Audio(sources=["microphone"], type="filepath"), outputs="text", title="Voice Command Assistant")31gesture_ui = gr.Interface(fn=handle_gesture, inputs=gr.Image(), outputs="text", title="Hand Gesture Assistant")32 33app = gr.TabbedInterface([voice_ui, gesture_ui], ["Voice Commands", "Hand Gestures"])34app.launch()35