Use Festival to read mpc status

I would like to use festival to read the title and artist of a now playing song, if anybody can point me in the right direction I would be grateful.

I’ve got most of it sorted out by using the script below, it works fine but it includes all the other bits from mpc status
(i.e.[paused] #24/65 0:38/3:11 (19%) volume: 5% repeat: off random: off single: off consume: off) which I don’t really want read out. Is it possible to just get the artist and track title from mpc?

!/bin/bash
write the mpc title and artist to a text file, and pause the currently playing track
mpc -f %title% > ~/title.txt; mpc -f %artist% > ~/artist.txt; mpc pause
introduce the track and artist
echo "Hi Steve, the currently playing track is " | festival --tts
read the track title
festival --tts ~/title.txt
echo “by the artist” | festival --tts
and the artist is
festival --tts ~/artist.txt
resume playing track
mpc play
clear both text files for next time
rm ~/title.txt
rm ~/artist.txt

Putting these 2 lines after writing the txt files and before festival reads them removes all but the first line and saves the file with it’s original name.

sed -i.bak ‘1!d’ ~/title.txt
sed -i.bak ‘1!d’ ~/artist.txt

This topic could be removed now as I have sorted it - but it might be of interest to others.

Have now found a neater way to do it and also send email with details at same time.

It’s called ~/current.sh and I use it from the 0 key on the remote.

#!/bin/bash
#write the mpc title and artist to a text file, and pause the currently playing song
mpc current -f “[This track is [%title% by ]%artist%]” > ~/titleartist.txt
mpc pause
festival --tts ~/titleartist.txt
mpc play
mpc current -f “[[%title% - %artist%]” | mail -s “Artist & title” an email address @ goes here
#clear text file for next time
rm ~/titleartist.txt

I have put a zipped copy of Pimusicbox for the Pi Zero including festival and lirc on the link below. It’s 850mb zipped and will need a 4gb card.
When installed and with sound on, you should get a ‘tada’ then festival man will read time and date, then the ip address of the pi. To change it - as it will get annoying go to nano /opt/musicbox/startup.sh and change at the bottom of file.
I think I’ve cleared any personal info from it, if you come across any please let me know so I can redo it.
Hope it’s useful to somebody.