Pi Won't Read Data Aloud

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
TechnoEquinox
 
Posts: 7
Joined: Mon Mar 28, 2016 1:06 pm

Pi Won't Read Data Aloud

Post by TechnoEquinox »

So I'm trying to create a device that grab weather data from an RSS feed and then verbally announce it over a speaker I have in my Pi's 3.5mm jack. Conveniently, I found a tutorial for this online here: http://garyhall.org.uk/speaking-weather ... ry-pi.html

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 $*
getWeather.php:

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);
?>
*Note* This isn't my final project, I'm going to be building a lot off of this, but I figured this would be a good foundation to lay to I can add a lot more in the future. Thanks in advance for any help you can offer!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Pi Won't Read Data Aloud

Post by adafruit_support_mike »

I'm afraid we don't have any experience with that software. Your best bet would be to contact the person who did the original project.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”