Skip to content

LintangWisesa/RPi_QuranSpeaker

Repository files navigation

simplinnovation

Raspberry Pi Quran Speaker

📋 Project Summary

Click the following picture to see the demo video:

Video

Qur'anic speaker for the online streaming of the Holy Qur'an. It can be controlled wirelessly via WiFi. Designed with Raspberry Pi 3B+/4B & Python: Flask, Eventlet, Gevent-websocket & Socket.io.


🐳 Docker Tutorial

If you prefer running the project using Docker for an isolated setup and a rather simpler installation steps, please follow the Docker guide here.


📋 Project Tutorial

This project is built on Raspberry Pi 3B+ with Raspbian OS and Python 3.x (I'm using 3.4 & 3.8). So make sure you've installed Python 3.x also git to clone this project from my github.

  • 1. Connect to WiFi & Check its IP

    Connect your Raspberry Pi to a WiFi connection, then check its IP address. On terminal type:

    $ ifconfig

    Your Pi's IP address must be various, it consists of some numbers with some dots like 123.456.78.910. Note your IP address!


  • 2. Clone this project

    Clone this project from my github repo. Download here or clone it from your terminal (make sure you've installed git on your Pi):

    $ git clone <repo_url>

  • 3. Install Python packages

    Install Python packages needed through pip:

    $ pip3 install flask flask-socketio eventlet gevent gevent-websocket python-vlc

  • 4. Run Flask application

    Go to the project root, then run its server application (app.py file).

    $ cd RPi_QuranSpekaer
    $ ./app.py

    The application (server) will be listening on port 5000, so you can access it via your Pi's web browser (for example Chromium): http://123.456.78.910:5000.


  • 5. Control it from other devices

    You can control it via your laptop, tablet or even a smartphone. First connect your device to a WiFi which your Raspberry Pi is connected to. Open your browser & go to your Pi's IP address on port 5000, for example: http://123.456.78.910:5000. You'll see something similar with your Pi display & try to play with it. Enjoy!


  • 6. Control it from other scripts

    You can pause/resume playback from other scripts on the Pi by running the following:

    ./pauser.py

    This script toggles the playing/paused mode. It will pause if it is currently in playing mode, and will resume if it is in paused mode. If it is in stopped mode, it will do nothing.

    You can also be specific if you only want to either pause or resume:

    ./pauser.py pause # pauses only, skips if paused or stopped
    ./pauser.py resume # resumes only, skips if playing or stopped
    ./pauser.py toggle # toggles, skips if stopped, the default behavior

    This is beneficial if you want to pause/resume playback beofre/after playing Adhan for example.

    Another scenario is to pause playback every night and resume in the morning. To do this add 2 cronjobs (type crontab -e and insert the below):

    0 22 * * * /home/pi/RPi_QuranSpeaker/pauser.py pause
    0 6 * * * /home/pi/RPi_QuranSpeaker/pauser.py resume
    

  • 7. Auto-start Quran Speaker on system boot

    We are going to use supervisord for auto-starting Quran Speaker on system boot and to ensure it is automatically restarted if it was stopped for any reason.

    1. Install supervisord:
      sudo apt install -y supervisor
    2. Place the following inside /etc/supervisor/conf.d:
      # /etc/supervisor/conf.d/quran_speaker.conf
      [program:quran_speaker]
      command=/home/pi/RPi_QuranSpeaker/app.py
      user=pi
    3. Reload supervisord:
      sudo systemctl reload
    4. Monitor the status of the service and check logs if necessary:
      sudo supervisorctl status quran_speaker
      sudo tail -f /var/log/supervisor/quran_speaker-stderr*

Lintang Wisesa 💌 lintangwisesa@ymail.com

Facebook | Twitter | Youtube | LinkedIn | :octocat: GitHub | Hackster

Hossam Hammady

Twitter | GitHub