Build a cheap audiobook player with Raspberry Pi


Audiobook with Raspberry Pi

The audiobooks or audiobooksThese are editions of the books that have been voice-recorded so that the visually impaired, those who have trouble reading or anyone who wants to enjoy a moment of literature while closing their eyes peacefully lying on the sofa, can use them.

There are already many audiobooks of the most important titles in literature, but if you want to listen to any other technical or non-technical book, you can listen to them, you can pass it to voice with some applications such as TextAloud (Loquendo) for Windows or Linux alternatives such as eSpeak, capable of converting any text to speech and storing it in an mp3 file. Or use a routine method, read the text and record it with a microphone. 

Well, to avoid depending on a tablet, laptop or computer, which is expensive to buy if you don't have one, you can create this audiobook reader. easy and very cheap using the famous Raspberry Pi and some equally cheap electronics.

Required components

To create your own Audiobook you will need the following materials:

  • Raspberry Pi plus the necessary accessories (case, power supply, cables, uSD 8GB card, etc...) that you can buy with this kit in our shop.
  • 1 button (electronic).
  • 2 resistors, one of 330 ohms and one of 10K.
  • 1 blue LED.
  • Single-wire cables for making connections.
  • Headphones or portable speakers.

This applies to the physical components. In addition, you will also have to download the following free of charge software:

  • ISO of the operating system Raspbian (in the case of purchasing the kit from our shop it is not necessary, since it already includes NOOBS on the SD card to be able to boot Raspbian).
  • mpd (Music Player Daemon) package
  • mpc package
  • mpd-python package
  • Package pyudev
  • And download a Python script we will show you later...

Let's invent together, let's get to work!

Well, what we want to create is a system that starts reading the audiobook at start-up and generates a pause system and then with the button we are going to implement. For easy playback. In addition, the system must remember where the playback was left off, so that the next time you want to continue listening to the book, it will continue from where it was left off the last time.

The system can only remember a bookSo you can only load one audiobook at a time, if you want to load another one (from a pendrive), the reminder of the previous one will be erased. This is a limitation of this device. But in exchange it offers many other advantages, such as convenience and ease of use and support for multiple formats (mp2, mp3, mp4, acc, ogg, wav, etc...).

We start the manufacturing process by creating the electronic circuit with the resistors, the button and the LED. This small and simple circuit must be connected to the GPIO pins of the Raspberry Pi board. Specifically, they will be connected to GPIO 17 and 24The rest of the wires will be connected to 3.3v and GND connections as shown in the following image.

Electronic circuit for AUdiolibro

For integrating everything in the boxIf you are using a Raspberry Pi, you can attach the cables you have used and the resistor to the inside of the Raspberry Pi case. Be careful not to place them in a place where they will scratch the case. A good area is the centre of the case, which is marked with a green circle in the image below. To fix the wires and resistors you can use tape or a hot glue gun.

Circuit housing

The button You should leave it outside the housing so that you can press it when you need it. To do this, you can either drill a small hole in the plastic housing with the help of a drill and place the button attached to it or simply make a grimace on the side and pull the wiring out with the button facing outwards so as not to damage the housing.

Now start the Raspberry Pi with the operating system RaspbianIf this is the first time you do it and you don't know how to do it, you can consult our tutorial on how to set up the Raspi.

From the command console We are going to install the necessary packages. To do this we will use the following commands:

sudo apt-get install mpd
sudo apt-get install mpc
sudo apt-get install python-mpd
sudo apt-get install python-pyudev

Continue along these lines to complete the configuration, creating a directory and generate the necessary symbolic links:

sudo mkdir -p /music/usb
sudo ln -s /var/lib/mpd /music/mpd
sudo ln -s /var/lib/mpd/music /music/mp3

Then you must copy the script that you have to download from this link in the /home/pi directory.

With the text editor nano, you must modify the Python script using the following command in the console (although you can also do it with your favourite text editor in graphical mode):

nano /home/pi/

Inside you must change the following:

LED = 24

We will now make a test. To do this, copy an mp3 audiobook (or any song would also work for the test) onto a USB flash drive. We just want to see if it plays it. Connect the stick to the USB stick (which you must have previously renamed with the name "1GB" without quotes) of the Raspi and type the following:

sudo mount /dev/sda1 /music/usb
sudo /etc/init.d/mpd stop
sudo rm /music/mp3/*
sudo cp /music/usb/* /music/mp3/
sudo umount /music/usb

You can now withdraw the USB port stick. Continue to do the following:

sudo rm /music/mpd/tag_cache
sudo /etc/init.d/mpd start
mpc clear
mpc ls
mpc ls | mpc add
sudo /etc/init.d/mpd restart
mpc play

Insert the headphones or speakers and type the following:

sudo python /home/pi/

As you can see, up to this point you need to keyboard and display to make the configurations, but that won't be the case from now on, you just need your little box with the Raspi and the headphones/speakers. To make it automatic, type this:

sudo crontab -e

And then add the following line for the script to start up every time you boot the system and you don't have to go through the previous steps again:

@reboot python /home/pi/ & sudo reboot

It will restart and after the restart, ready. Plug the USB stick back in and the LED should light up, indicating that the audio is being copied to the Raspi and once it goes out it means you can remove the stick from the USB. To start playback press the button. If you want to stop, press the stop button again if you wish.

I hope you enjoy a lot this little project for your Raspberry Pi, any doubt you can use the comments.

2 thoughts on “Fabrica un reproductor de audiolibros barato con la Raspberry Pi”

  1. typing the commands sudo rm /music/mp3/*,sudo cp /music/usb/* /music/mp3/ gives an error and the audio does not play.
    any suggestions or what I could do about it. thanks.
    I am doing this project for my systems class and I am very interested in knowing how I can make it work.

    1. Hello,

      Please report the error message so that we can help you.

      Thank you and best regards!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top