HomeGenie Forum

General Category => General Discussion => Topic started by: Bobpick on January 07, 2015, 04:26:33 PM

Title: Adding sound
Post by: Bobpick on January 07, 2015, 04:26:33 PM
Right now, if there is movement on my front porch, eventually (about 1 minute later) I get an email from a program I set up.

I'd like to have the program play a wav or mp3 file so when I'm working at the computer, I know there is someone there.

Any ideas?
Title: Re: Adding sound
Post by: bkenobi on January 07, 2015, 05:06:26 PM
I use a X10 chime module for this, but you should be able to either have the HG server play a sound or say something.  I believe if you want it to talk, you'd use something like:

Code: [Select]
Program.Say("Someone is at the front door");
I don't know the code for playing audio.
Title: Re: Adding sound
Post by: Gene on January 07, 2015, 05:55:16 PM
Or use Program.Play (http://www.homegenie.it/docs/doxy/de/d1f/class_home_genie_1_1_automation_1_1_scripting_1_1_program_helper.html#a5407b247ef935a9cb1906420209e2be1).
Title: Re: Adding sound
Post by: Bobpick on January 07, 2015, 06:53:05 PM
I had no idea I could add TTS.

Now, if I could only get speech working with Firefox.
Title: Re: Adding sound
Post by: bkenobi on January 07, 2015, 08:36:54 PM
What would the proper format be for playing a local file?

/home/pi/file.wav

Also, it asks for a waveURL.  What formats are compatible (wave only presumably)?
Title: Re: Adding sound
Post by: drpepper on January 10, 2015, 12:52:19 AM
Program.Play("file:///home/pi/file.wav")

If you want to use mp3 you can implement the same logic that Utility.Say does to convert it using the lame encoder bundled with HG.

https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Service/Utility.cs#L165 (https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Service/Utility.cs#L165)
Title: Re: Adding sound
Post by: bkenobi on January 10, 2015, 03:11:56 AM
Seems like it would be good for the Play utility to detect mp3 files and automatically convert them prior to playing the wave.  Maybe that should be a feature request.
Title: Re: Adding sound
Post by: drpepper on January 10, 2015, 03:43:20 AM
Or a pull request... ;)

I've refactored Utility.Play on my end because as it stands it only calls aplay which doesn't run on Windows. You could copy the lame encoder lines from the Say method or factor them out into a method that both Play and Say could use, then just test/case the filename for mp3/wav.
Title: Re: Adding sound
Post by: DutchHans on January 10, 2015, 07:24:51 PM
Hi, there's a perfect solution for your problem. Jshan has created a notification module for android. On android there's a program "voice notify" this speaks out loud all notifications via tts instant. You can add your notifications in your program, like"the garage doors are open" . I haven't had time to test it myself, but it looks really promising.
Hope this helps.
Bye, Hans