Skip to content

chloepilonv/voice-nightlight-raspberrypi

Repository files navigation

πŸŒ™ Voice Nightlight (Veilleuse)

A voice-activated nighttime note recorder for Raspberry Pi. Record your thoughts at night without grabbing your phone. Transcriptions are delivered to your phone the next morning.

🎯 Features

  • Wake word activation - Say "Porcupine" or "Jarvis" to start recording
  • Automatic transcription - Uses OpenAI Whisper API
  • Phone delivery - Sends notes via Telegram or Email
  • Hands-free operation - No screens, no phones, just voice
  • Local storage - All recordings saved on the Pi

πŸ“‹ Requirements

Hardware

  • Raspberry Pi 4 Model B
  • Microphone (USB mic recommended, or headphones with inline mic)
  • microSD card (8GB+)
  • Power supply

Software

  • Raspberry Pi OS (Bullseye or later)
  • Python 3.8+
  • Internet connection

πŸš€ Quick Start

1. Clone or copy files to your Pi

cd ~
mkdir voice-nightlight
cd voice-nightlight
# Copy all project files here

2. Run installation script

chmod +x install.sh
./install.sh

3. Configure API keys

Edit the .env file with your credentials:

nano .env

Required API Keys:

Picovoice (Wake Word Detection)

  1. Go to https://console.picovoice.ai/
  2. Sign up for free account
  3. Create an access key
  4. Copy key to PICOVOICE_ACCESS_KEY in .env

OpenAI (Whisper Transcription)

  1. Go to https://platform.openai.com/api-keys
  2. Create new API key
  3. Copy key to OPENAI_API_KEY in .env
  4. Cost: ~$0.006 per minute of audio

Telegram (Recommended Delivery Method)

  1. Open Telegram and message @BotFather
  2. Send: /newbot
  3. Follow instructions, copy your bot token
  4. Add to TELEGRAM_BOT_TOKEN in .env
  5. Message @userinfobot to get your chat ID
  6. Add to TELEGRAM_CHAT_ID in .env
  7. Start a chat with your new bot

Email (Alternative)

For Gmail:

  1. Enable 2FA on your Google account
  2. Create App Password: https://support.google.com/accounts/answer/185833
  3. Use app password in SMTP_PASSWORD

4. Test your microphone

# List audio devices
arecord -l

# Record 5 second test
arecord -d 5 -f cd test.wav

# Play it back
aplay test.wav

If your microphone isn't working:

# Check audio configuration
alsamixer

# Select the right input device
sudo nano /etc/asound.conf

5. Run the application

source venv/bin/activate
python3 voice_nightlight.py

You should see:

πŸŒ™ VOICE NIGHTLIGHT - Ready for bedtime notes
πŸ‘‚ Listening for wake word: 'porcupine'...

6. Test it

  1. Say: "Porcupine" (wait for beep/confirmation)
  2. Speak your note
  3. Say: "Stop recording" or press Ctrl+C
  4. Wait for transcription and delivery
  5. Check your Telegram or email!

πŸ€– Autostart on Boot (Optional)

To make it run automatically when Pi boots:

chmod +x setup_autostart.sh
sudo ./setup_autostart.sh

Control the service:

sudo systemctl start voice-nightlight   # Start
sudo systemctl stop voice-nightlight    # Stop
sudo systemctl status voice-nightlight  # Check status
sudo journalctl -u voice-nightlight -f  # View logs

πŸ“± Delivery Methods

Telegram (Recommended)

  • βœ… Instant notifications
  • βœ… Easy setup
  • βœ… Works everywhere
  • βœ… Free

Email

  • βœ… Universal
  • ⚠️ May be delayed
  • ⚠️ Might go to spam

🎀 Usage Tips

Wake Words:

  • "Porcupine" (easier)
  • "Jarvis" (sounds cooler)

Recording:

  • Speak naturally, 1-2 feet from mic
  • USB mic works better than headphone mic
  • Quiet room = better transcription

Stopping:

  • Say "stop recording"
  • Or just press Ctrl+C on the Pi
  • Auto-stops after 5 minutes

πŸ“ File Structure

voice-nightlight/
β”œβ”€β”€ voice_nightlight.py    # Main application
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ .env                   # Your API keys (DO NOT COMMIT)
β”œβ”€β”€ .env.example          # Template
β”œβ”€β”€ install.sh            # Setup script
β”œβ”€β”€ setup_autostart.sh    # Autostart configuration
β”œβ”€β”€ recordings/           # Audio files (created automatically)
β”‚   β”œβ”€β”€ recording_20240108_235959.wav
β”‚   └── recording_20240108_235959.txt
└── README.md            # This file

πŸ”§ Troubleshooting

"No audio device found"

# Check if mic is detected
arecord -l

# If using USB mic, try:
sudo nano /boot/config.txt
# Add: dtparam=audio=on

# Reboot
sudo reboot

"Porcupine error: Invalid access key"

"OpenAI API error"

"Telegram not receiving messages"

  • Make sure you started a chat with your bot
  • Verify chat ID with @userinfobot
  • Check bot token is correct

Poor transcription quality

  • Use a better microphone (USB recommended)
  • Reduce background noise
  • Speak clearly, not too fast
  • Try changing language in code (language="en")

πŸ’° Cost Breakdown (MVP)

  • Raspberry Pi 4: ~€50 (one-time)
  • USB Microphone: ~€15 (one-time)
  • OpenAI Whisper: ~€0.006/minute
  • Picovoice: Free tier (1 wake word)
  • Telegram: Free

Example: 5 minutes of recording per night = €0.03/night = €1/month

🏭 Production Roadmap

For mass production, consider:

  1. Hardware:

    • ESP32-S3 with built-in WiFi (~€5)
    • I2S MEMS microphone (~€2)
    • LED nightlight PCB
    • 3D printed enclosure
    • USB-C power
  2. Software:

    • Edge ML for wake word (no API cost)
    • Cloud backend for transcription
    • Mobile app for setup & delivery
    • OTA updates
  3. Features:

    • Multiple user profiles
    • Smart scheduling (only active at night)
    • Voice activity detection
    • Better stop word detection
    • Data encryption

πŸ“„ License

MIT License - Feel free to use for personal or commercial projects!

🀝 Contributing

This is an MVP. Ideas for improvement:

  • Better stop phrase detection (Vosk)
  • Local Whisper (faster-whisper)
  • iOS Shortcuts integration
  • Multi-language support
  • Voice activity detection
  • Cloud sync
  • Mobile app
  • LED status indicators

πŸ’‘ Tips for Better Sleep

  • Place the device 1-2 meters from your bed
  • Use a soft nightlight (not bright)
  • Speak at normal volume
  • Don't stress about perfect transcription
  • Review notes in the morning, not immediately

Made with πŸ’™ for better sleep and captured ideas

Questions? Issues? Open an issue or contribute!

About

A voice-activated nighttime note recorder for Raspberry Pi. It records my ideas at night without having to grab my phone, and sends an email to me the next morning with all the ideas.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors