more G-Labs products

Author Topic: Adding sound  (Read 2387 times)

January 07, 2015, 04:26:33 PM
Read 2387 times

Bobpick

  • *
  • Information
  • Newbie
  • Posts: 22
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?

January 07, 2015, 05:06:26 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
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.

January 07, 2015, 05:55:16 PM
Reply #2

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer

January 07, 2015, 06:53:05 PM
Reply #3

Bobpick

  • *
  • Information
  • Newbie
  • Posts: 22
I had no idea I could add TTS.

Now, if I could only get speech working with Firefox.

January 07, 2015, 08:36:54 PM
Reply #4

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
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)?

January 10, 2015, 12:52:19 AM
Reply #5

drpepper

  • *
  • Information
  • Newbie
  • Posts: 23
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

January 10, 2015, 03:11:56 AM
Reply #6

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
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.

January 10, 2015, 03:43:20 AM
Reply #7

drpepper

  • *
  • Information
  • Newbie
  • Posts: 23
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.

January 10, 2015, 07:24:51 PM
Reply #8

DutchHans

  • **
  • Information
  • Jr. Member
  • Posts: 39
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