This is where I am at:
mplayer works as it is supposed to, however, when I try and add the line "nolirc=yes" to "/etc/mplayer/mplayer.conf" through nano, I get an error that says "Error writing /etc/mplayer/mplayer.conf: No such file or directory". mplayer does however work when I play test audio with "$ mpg123 example.mp3" on the command line.
I went through all the other steps, creating the speech.sh file, installing PHP, and then creating the php file, I change all the directories for my pi (I have everything under /home/pi), I give it the correct permissions, and then when I try to run it (sudo php getWeather.php), the pi stalls for about 10 seconds, doesn't write anything to the command line, and then completes running the file. No audio is played however.
I don't know if anyone has either found a better way to do this, or If I am just missing something here, but I've been tinkering with it for a while and I'm lost.
Here is my attached code just incase:
speech.sh:
Code: Select all
#!/bin/bash
say()
{
local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?tl=en&q=$*";
}
say $*
Code: Select all
<?php
// first say welcome etc.
$title = "Hi, its me, Wanda, with the weather for the next three days.";
$speech="/home/pi/speech.sh"." ".$title;
exec($speech);
// load RSS file from BBC weather website
$rss = simplexml_load_file('http://open.live.bbc.co.uk/weather/feeds/en/hu17/3dayforecast.rss');
// loop through the three day forecast, saying the weather for each day
foreach($rss->channel->item as $item) {
$title = (string)$item->title[0];
$title = str_replace('°C ', ' degrees.', $title);
$title= preg_replace("/\([^)]+\)/","",$title);
$speech="/home/pi/speech.sh"." ".$title;
exec($speech);
}
// now say goodbye etc.
$title = "Thats the end of the 3 day forecast. Enjoy the weather, people!";
$speech="/home/pi/speech.sh"." ".$title;
exec($speech);
?>