Easy (Easier) way to make your vera speak and do sound alerts

Hello,
I have been playing with setting up my house with a vera lite, thermostat, 2 cameras, garage door opener, garage door sensor, 3 locks, and around 30 intermatic dimmers, scene controllers and switches. Its all working pretty well and I’m getting into some more advanced programming. I have worked up a way to get audio alerts to happen when scenes are called.

What it does:
When a scene is called, an audio alert is played out of a computer speaker.

What you need:

-a windows PC (Doesn’t have to be fancy, I used an old ASUS netbook) You could use your home computer
-VLC Media Player (found here [url=http://www.videolan.org/vlc/index.html]http://www.videolan.org/vlc/index.html[/url])

VLC Setup:
First step is to download and install VLC Media Player.

Step two; you need to change the settings on the hosts file for the VLC Media Player in order for outside IPs to access it… This is essential for your vera to be able to talk to the media player.
This hosts file is located in C:\Program Files\VideoLAN\VLC\lua\http
The file you need to edit is “.hosts”.
Remove the “#” sign before the address block you want to enable… If in doubt, make the last three lines look like this:

# The world (uncommenting these 2 lines is not quite safe)
::/0
0.0.0.0/0

Step three is to enable what is called the “Web Interface” see Screenshot:[url=http://www.exoid.com/R1F/vlc/vlc1.png]http://www.exoid.com/R1F/vlc/vlc1.png[/url]

Next you need to make sure you have some audio files on the computer for vera to call via the web interface…
I simply made a directory on my PC called “C:\Audio” and placed a file in there called “light_on.wav”

The last step is to edit your luup code on the scene that you want to make speak.
Here is an example:

os.execute(‘curl -g “http://192.168.1.117:8080/requests/status.xml?command=in_play&input=file:///C:/Audio/light_on.wav”’)

Substitute the 192.168.1.117 in my code above for the IP address of your PC!

Be sure to hit the save the luup code underneath the luup code, and then confirm your change to the scene, and then finally hit the big red button to save.

Then Run your Scene and listen to your PC speak!!!


You can also use this web interface to do lots of different things with VLC, you can play a video file, pause, play, skip, whatever… using commands.

For reference, see the file “README.txt” in the “VideoLAN\VLC\lua\http\requests” folder

Hope this is helpful for some, I’ve seen some doing something kindof similar with itunes and such, but this seems much easier and straightforward.

I’m thinking of pairing this with a whole house FM transmitter, so I can play audio around the whole house using cheap FM Radios as monitors.

Hi C!

Great idea!

That was work! ( i modified the input file was google.translate tts :slight_smile: )

Future: play on Ipad ?! :slight_smile:

Hi

I’m using a Mac Mini would the instructions be the same?

Also would like to use Google TTS and wondered if this line would work

os.execute(‘curl -g “http://192.168.1.66:8080/requests/status.xml?command=in_play&input=http://translate.google.co.uk/#auto/en/Lounge%20Light%20On”’)

any help would be much appreciated

cheers

m0jon

@cbutters

Thank you for a great idea! I had been looking for a simple solution to provide a confirmation when activating functions using keyfob remotes. Five minutes downloading and installing VLC and it’s done. The ATT Natural Voices site is brilliant so thanks for that too. I can even have a female British voice giving me calm reassurance that my instructions have been received. ;D

It does seem to be necessary to have VLC already running on the target PC when a command is received so it looks as though it needs to be in Windows Startup.

Hi All

Getting there slowly.

Ended up saving the .wav files on a website I have and the using the following link

os.execute(‘curl -g “http://192.168.1.66:8080/requests/status.xml?command=in_play&input=http://www.gambitman.co.uk/Audio/garageon.wav”’)

which gets Vera to speak when a scene is run

For the life of me I can not work out the correct path locally to my

/Macintosh HD/Audio/garageon.wav

Cheers

m0jon

For the web server on the Mac? Would expect you need to “cheat” with a softlink & a .htaccess override on the mac?

Hi sjolshagen

I didn’t think it would be easy with it being a MAC !!!

Now trying to work out the correct link so i can use google translate instead of loading lots of .wav files on my web space

m0jon

Instead of running this on a scene is there a way to modify the code to run on the device. When I turn the switch on it plays one wav file but when i turn the switch off it plays another wav file?
Thanks

[quote=“m0jon, post:7, topic:174270”]Hi sjolshagen

I didn’t think it would be easy with it being a MAC !!!

Now trying to work out the correct link so i can use google translate instead of loading lots of .wav files on my web space

m0jon[/quote]
i hate MAC so i dont know much about it. but it seems that if you have a player on it with a http server for the request, it can actually access that dir. so why not put the audiofiles in there and perhaps check permissions that they are same as for the index.html or index.php or whatever its using.

[quote=“spudjr, post:8, topic:174270”]Instead of running this on a scene is there a way to modify the code to run on the device. When I turn the switch on it plays one wav file but when i turn the switch off it plays another wav file?
Thanks[/quote]
i was thinking about this and it should be possible to put this in a device implementation file. dont know in what degree it messes up the system though.

[quote=“spudjr, post:8, topic:174270”]Instead of running this on a scene is there a way to modify the code to run on the device. When I turn the switch on it plays one wav file but when i turn the switch off it plays another wav file?
Thanks[/quote]As @Da_JoJo says, you could probably add this to the device’s implementation file but you would have to do it for all the different devices you want to “speak”. Your system would then be non-standard and possibly unable to use firmware updates without reapplying the modifications.

What’s your issue with scenes? You could use a single scene for all spoken alerts. Add a trigger for each event that you want to “speak” and put the Luup call in the Luup event page for the trigger. It is only going to take about ten seconds to add each new event using copy/paste for the Luup line.

No issues with scenes. The code with scenes code works very well. I was asking as sometimes people in the house press the wrong button on the control panel and just wanted verbage when they did it. Thats all

to come back on this… i have found a way…
just put it in a function and add this luup code to vera edit startup lua so it will load the function when vera starts
then use function call for calling the VLC server.
this way you have no problems with firmware updates. just add the function back and you’ll be fine.
im fiddling a bit with the thing and found you can also play movie files this way. so im looking for a way to open webcamstream in it ^^

You could use a single scene for all spoken alerts. Add a trigger for each event that you want to "speak" and put the Luup call in the Luup event page for the trigger. It is only going to take about ten seconds to add each new event using copy/paste for the Luup line.
I decided this would be a good way to lose a bunch of scenes I was using for announcements. Now I have a single [i]Speak[/i] scene with multiple triggers. The main Luup for the scene (under the [i]LUUP[/i] tab) is:

if (wavFile) then os.execute('curl -g "http://192.168.1.248:8080/requests/status.xml?command=in_play&input=file:///C:/Alerts/'..wavFile..'.wav"') wavFile = nil end

Change the 192.168.1.248 part to the IP address of the PC where VLC Media Player is installed. Change the C:/Alerts/’ part to the folder on this PC where your alert wavs are stored.

Then each trigger has this code in Luup Event:

wavFile = "<filename>" return true

is the name of the wav file for this trigger - without the .wav extension.

So for each new event where you want an announcement, add a new trigger for the relevent device and then add the two lines to the Luup Event page. Create the wav file using the AT&T Natural Speech Demo website and save it in your alerts folder. Job done. Well maybe…

I have found that VLC Media Player can sometimes clip the first syllable when playing the speech files. I fix this by opening the wav files in an audio editor (Audacity is good and free :slight_smile: ) and adding 0.15 seconds of silence to the beginning. This stops it being clipped and waiting another 150ms for the announcement is not noticable.

I also found that the AT&T Natural Speech Demo can be manipulated by the judicious use of punctuation. Heating, on, Heating. On. and Heating on. result in quite different pronunciations.

I recently worked out something similar. PHP code on an always-running Windows PC:

[tt]
$VoiceObj = new COM(“SAPI.SpVoice”);
$VoiceObj->Voice = $VoiceObj->GetVoices()->Item(5);

$VoiceObj->Speak($_GET[‘t’]);

echo ‘1’;
[/tt]

(note - item 5 is the 5th voice. IIRC, the index is zero-based).

In my startup Luup:

[tt]
function say(text)
t = escape(text)
durl = “http://IP OF WIN MACHINE/say/?t=” … t
local status, result = luup.inet.wget(durl, 1)
end
[/tt]

(save this as index.php - in the “say” folder of server root in this example.)

Then, whenever I want a task to say something, I can do

[tt]say(‘text that I want said.’)[/tt]

in the Luup of a scene.

For instance, to speak today’s hi/low temps (using the Weather Underground plugin)

[tt]
local lul_hi = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”, “CurrentTemperature”, 7)
local hi_num = tonumber(lul_hi)
local lul_lo = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”, “CurrentTemperature”, 6)
local lo_num = tonumber(lul_lo)

local text = "Today’s high will be " … hi_num … " degrees. The low is " … lo_num
say(text)
[/tt]

6 and 7 are the device IDs of the high and low temp objects (created by the weather plugin), respectively.

@ih8gates
i put the php in my webserver and did : https://webserver.nl/talk.php?t=blabla
and it give me : $VoiceObj = new COM(“SAPI.SpVoice”); $VoiceObj->Voice = $VoiceObj->GetVoices()->Item(5); $VoiceObj->Speak($_GET[‘t’]); echo ‘1’;
is there something else required for this to work ?

Ah - you’ll need the MS speech API installed on that machine.

http://www.microsoft.com/en-us/download/details.aspx?id=10121

If that’s installed correctly, you should be able to test it under control panel >> speech (there will be a TTS tab)

Then test your talk.php to make sure that’s working correctly.

ah ok… thought that was allready implemented in win8.1 , apparently not…
edit: installed tts file: SpeechSDK51.exe and msttss22L.exe and still does same thing… tts works from “Control Panel\All Control Panel Items\Speech Recognition” though

Something else I did that’s been handy:

I have spoken feedback distributed through my house using a whole-house FM transmitter and some always-on clock radios as receivers.

The always-on PC that handles Vera audio is my home theater PC. It’ll play music/videos/etc through my TV, but I wanted discrete control of audio so that when the TV was on, the audio didn’t get sent all over the house.

My solution was to pick up an inexpensive (~$6) USB sound dongle. It looks like a sound card to the PC. I set it as the default audio device for TTS. Everything else goes to the TV/stereo via the default sound card.

are you using MS IIs webserver for this ? i use apache clone
does it need settings in php.ini ?