close-circle
Close
0%
0%

piHole - Raspberry Pi text-to-speech msg server

Not sure whether to contact your loved one via email, SMS, Skype, WhatsApp or FB messenger? Just SHOUT - with a text-to-speech web server.

TM
Similar projects worth following
close
A simple Raspberry Pi Zero project that reads out incoming web text messages over a speaker.
By default, it reads with a Northern accent, but there's nowt wrong with that.

A couple of days before Christmas I picked up a Raspberry Pi Zero (thank you Microcenter!) and was looking for a short, get-to-know-you project that wouldn't distract from my social (drinking) obligations over the holidays.

So here's "piHole", a simple web server that accepts text messages via an HTML form and reads them out over a central speaker using "eSpeak" text-to-speech software.

piHole.service

Copy to /lib/systemd/system. See instructions for pathname and permissions changes that may be required.

service - 178.00 bytes - 01/02/2016 at 23:45

download-circle
Download

piHole_log.html

HTML template for "/log" the message log.

HyperText Markup Language (HTML) - 998.00 bytes - 01/02/2016 at 23:25

download-circle
Download

piHole_root.html

HTML template for "/" the main menu.

HyperText Markup Language (HTML) - 264.00 bytes - 01/02/2016 at 23:25

download-circle
Download

piHole_gpio.html

HTML template for "/gpio" an I/O pin control page.

HyperText Markup Language (HTML) - 851.00 bytes - 01/02/2016 at 23:25

download-circle
Download

piHole_say.html

HTML template for "/say", the message entry form.

HyperText Markup Language (HTML) - 655.00 bytes - 01/02/2016 at 23:25

download-circle
Download

View all 7 files

  • 1 × Any kind of Raspberry Pi with Raspbian Jessie. (I'll try to link to instructions for older Raspbians as I go along.)
  • 1 × USB Sound Card (if using Pi Zero).
  • 1 × PC speakers
  • 1 × A powered USB hub.
  • 1 × A USB WiFi dongle (Or working ethernet connection.)

  • 1
    Step 1

    Preconditions

    I'm going to assume that you have a Raspberry Pi with a working installation of Raspbian Jessie and a working network connection. Smarter people than me have written instructions for getting these things working:

    https://www.raspberrypi.org/

    https://learn.adafruit.com/category/raspberry-pi

    https://www.google.com

    (I will try to link to instructions for older versions of Raspbian as I go along.)

  • 2
    Step 2

    Install Software

    Install the espeak text to speech system:

    sudo apt-get install espeak

    and the pip library management tool:

    sudo apt-get install python-pip
    Now the flask Python web server library:
    sudo pip install flask
    and Siegfried Gevatter's Python espeak wrapper:
    sudo apt-get install python-espeak
    (I initially used the pyttsx library but found that it tends to hang after long messages - probably an internal buffer overflow somewhere.)
  • 3
    Step 3

    Configure Sound Output (Pi Zero only)

    If you're using any other kind of Pi, skip this step, a USB sound card is only needed if you're using the Pi Zero, which doesn't have an audio jack.

    Even with the Zero, you can avoid using a USB sound card by either using an HDMI cable and your TV's speakers:

    (Raspberry Pi audio configuration instructions here.)

    or by building a simple RC filter and connecting to PWM output on GPIO 18:

    (Adafruit tutorial here.)

    If I was serious about deploying piHole on the Pi Zero I'd choose this second option. I'll have to get around to it some day anyway, but for now I have a cheap USB sound card dongle lying around (previously used with a BBB), so I'll use that.


    Configuring a USB Sound Card on the Pi Zero

    I'm going to assume that you're using a recent (Jessie) version of Raspbian here. If you're using an older version of Linux, you'll have to modify the file

    /etc/modprobe.d/alsa-base.conf

    following instructions like those here:

    (Old instructions for switching audio output.)

    On Raspbian Jessie we'll be modifying the file

    /etc/alsa/alsa.conf
    First let's identify our card. Plug in your USB sound card and run the command
    aplay -l

    This will display a "List of PLAYBACK Hardware Devices". The first device listed,

    card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]

    is the default PWM output described at the Adafruit link above. The second listed device should be your USB Sound Card. For me the output is:

    card 1: Set [C-Media USB Headphone Set], ...

    Which is great news as the "C-Media USB Headphone Set" driver is pre-installed in Jessie.

    If your card type is CM108 or CM109, you'll have to install a driver by following the instructions at:

    (Another great tutorial by Lady Ada.)

    Assuming you've got that done, and you're running Raspbian Jessie, we can

    sudo nano /etc/alsa/alsa.conf

    changing defaults.ctl.card and defaults.pcm.card from the default 0 to 1.

    (Don't forget to backup alsa.conf before editing!)

    To avoid the default card switching back to 0, I also modified the file .asoundrc in my home directory (/home/pi.).

    Mine now reads

    pcm.!default plughw:Set
    ctl.!default plughw:Set

    where "Set" is the name of my USB Sound Card: the word immediately after "card 1: " in the output from "aplay -l" above.

    (You can also see your card's name by running "aplay -L", some card names are set to "Audio".)

    After rebooting, we should now be good to go. Connect the headphone jack of the USB sound card to some PC speakers and enter

    aplay /usr/share/sounds/alsa/Front_Center.wav
    and you should hear a young lady saying "Front Centre". If not, reboot and try again. If still not, give up. Seriously. Audio configuration is, and probably always willbe, the worst part of Linux (worse than WiFi support and suspend/resume).

View all 15 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates