Control YouTube with your face and voice! An enhanced version of FaceMouse that integrates facial gesture control with YouTube playback control and voice commands.
- Head Movement: Control mouse cursor by moving your head
- Eye Blinks: Different blink patterns control different actions
- Real-time Processing: Smooth, responsive facial tracking
- Play/Pause: Toggle video playback
- Volume Control: Increase/decrease volume
- Video Navigation: Next/previous video, seek forward/backward
- Video Controls: Like, subscribe, fullscreen toggle
- Settings Access: Open YouTube settings menu
- Playback: "play", "pause", "stop"
- Audio: "mute", "unmute", "volume up", "volume down"
- Navigation: "next", "previous", "forward", "backward"
- Interface: "fullscreen", "settings", "like", "subscribe"
- Mouse Mode: Traditional mouse control with facial gestures
- YouTube Mode: YouTube-specific controls with voice commands
- Webcam: Any standard webcam (built-in or external)
- Microphone: For voice commands
- Internet Connection: For YouTube access and model download
- Minimum RAM: 4GB (8GB recommended)
- Processor: Intel i3 or equivalent (i5+ recommended)
- Operating System: Windows 10/11, macOS, or Linux
- Python: 3.8 or higher
- Chrome Browser: Latest version (for YouTube control)
- Visual C++ Redistributable: For Windows users
pip install -r requirements.txt
# Download the facial landmark model
curl -O http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
# Decompress the model
python -c "import bz2; data = bz2.decompress(open('shape_predictor_68_face_landmarks.dat.bz2', 'rb').read()); open('shape_predictor_68_face_landmarks.dat', 'wb').write(data); print('โ
Model downloaded and decompressed successfully!')"
python face_mouse_youtube.py
FaceMouse-YouTube/
โโโ face_mouse_youtube.py # Main application (enhanced with YouTube control)
โโโ youtube_controller.py # YouTube control module
โโโ test_youtube_controller.py # Test script for YouTube functionality
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ shape_predictor_68_face_landmarks.dat # Facial landmark model (99MB)
โโโ shape_predictor_68_face_landmarks.dat.bz2 # Compressed model file
python face_mouse_youtube.py
h
- Show help menuy
- Toggle YouTube mode ON/OFFq
- Quit application
- 1 Blink โ Left Click
- 2 Blinks โ Double Click
- 3 Blinks โ Mouse Down (Drag)
- 4+ Blinks โ Right Click
- 1 Blink โ Play/Pause video
- 2 Blinks โ Next video
- 3 Blinks โ Mute/Unmute
- 4 Blinks โ Fullscreen toggle
- 5 Blinks โ Like video
- 6 Blinks โ Volume up
- 7 Blinks โ Volume down
- 8+ Blinks โ Subscribe
- "play" - Start/resume playback
- "pause" - Pause playback
- "mute" - Mute audio
- "unmute" - Unmute audio
- "volume up" - Increase volume
- "volume down" - Decrease volume
- "next" - Next video
- "previous" - Previous video
- "fullscreen" - Toggle fullscreen
- "like" - Like current video
- "subscribe" - Subscribe to channel
- "settings" - Open settings menu
- Download Python 3.8+ from python.org
- During installation, check "Add Python to PATH"
- Verify installation:
python --version
# Upgrade pip first
python -m pip install --upgrade pip
# Install all required packages
pip install -r requirements.txt
# Download compressed model (64MB)
curl -O http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
# Decompress model (creates 99MB .dat file)
python -c "import bz2; data = bz2.decompress(open('shape_predictor_68_face_landmarks.dat.bz2', 'rb').read()); open('shape_predictor_68_face_landmarks.dat', 'wb').write(data); print('โ
Model decompressed successfully!')"
# Test core dependencies
python -c "import cv2, dlib, mouse, numpy as np, scipy; print('โ
Core dependencies working!')"
# Test YouTube controller
python -c "from youtube_controller import YouTubeController; print('โ
YouTube controller ready!')"
# Test audio system
python -c "import pygame; pygame.mixer.init(); print('โ
Audio system working!')"
python face_mouse_youtube.py
# Check available cameras
python -c "import cv2; print([i for i in range(5) if cv2.VideoCapture(i).isOpened()])"
# Try different camera index in code (change cv2.VideoCapture(0) to cv2.VideoCapture(1))
# Install Chrome driver manually
python -c "from webdriver_manager.chrome import ChromeDriverManager; print(ChromeDriverManager().install())"
# Or update Chrome to latest version
# Test microphone
python -c "import speech_recognition as sr; sr.Microphone().list_microphone_names()"
# Install PyAudio dependencies for Windows
pip install pipwin
pipwin install pyaudio
# Run as administrator (Windows)
# Or check antivirus settings
# Reinstall specific package
pip uninstall package_name
pip install package_name
# Clear pip cache
pip cache purge
Error | Solution |
---|---|
No module named 'dlib' |
pip install dlib |
No module named 'selenium' |
pip install selenium |
Chrome driver not found |
pip install webdriver-manager |
Microphone not working |
pip install pyaudio |
OpenCV camera error |
Check camera permissions/connections |
Model file not found |
Download and decompress the facial model |
Edit these values in face_mouse_youtube.py
:
sclFact = 6 # Cursor movement sensitivity (default: 6)
EYE_AR_THRESH = 0.20 # Blink detection threshold (default: 0.20)
vs = cv2.VideoCapture(0) # Change 0 to 1, 2, etc. for different cameras
Edit youtube_controller.py
for browser preferences:
chrome_options.add_argument("--start-maximized") # Window size
chrome_options.add_argument("--disable-gpu") # Performance
- Good Lighting: Ensure well-lit environment
- Stable Position: Sit at consistent distance from camera
- Reduce Background Movement: Minimize distractions behind you
- Close Other Applications: Free up system resources
- Use External Webcam: Better quality than built-in cameras
# Update graphics drivers
# Close unnecessary background applications
# Use SSD storage for better I/O performance
Modify gesture mappings in youtube_controller.py
:
self.gesture_commands = {
1: 'play_pause', # 1 blink = play/pause
2: 'next', # 2 blinks = next video
# Add your custom gestures here
}
# Add language support in youtube_controller.py
recognizer.recognize_google(audio, language='en-US') # English
recognizer.recognize_google(audio, language='es-ES') # Spanish
- Check the troubleshooting section above
- Verify all dependencies are installed
- Test individual components before full integration
- Check console output for specific error messages
- Q: Can I use it without a camera?
- A: The facial gestures require a camera, but voice commands work without camera
- Q: Does it work on Mac/Linux?
- A: Yes, with appropriate dependencies installed
- Q: Can I customize the gestures?
- A: Yes, modify the gesture mappings in the code
This project is based on the original FaceMouse project. Please refer to the original license terms.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
๐ฎ Enjoy hands-free YouTube control with FaceMouse!
Made with โค๏ธ for the computer vision and automation community
pip install -r requirements.txt
curl -O http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
python -c "import bz2; data = bz2.decompress(open('shape_predictor_68_face_landmarks.dat.bz2', 'rb').read()); open('shape_predictor_68_face_landmarks.dat', 'wb').write(data); print('โ
Setup complete!')"
python face_mouse_youtube.py
- Press 'y' โ YouTube mode
- Press 'h' โ Help
- Press 'q' โ Quit