[HSSCRIPT] SBPLay - Play announcement MP3's

Forum over Homeseer scripts (DUTCH forum)

Moderators: TANE, Ruud

Post Reply
Jeffrey
Member
Member
Posts: 136
Joined: Tue Jun 09, 2009 3:34 pm
Location: Netherlands

[HSSCRIPT] SBPLay - Play announcement MP3's

Post by Jeffrey »

After 4 days of coding/testing/troubleshooting SBPlay 0.1 is a fact.

---------------------------------------
General Information
---------------------------------------
Scriptname : SBPlay.vb
Type : Homeseer script

---------------------------------------
Description
---------------------------------------
Play's an announcement MP3 on all your Squeezebox Server connected devices. This can be the Squeezebox, Transporter, SoftSqueeze, SqueezePlay, etc.

---------------------------------------
Installation
---------------------------------------
1. Create a folder on your Squeezebox Server and copy the <i>SBPlay_Silence.mp3</i> and <i>SBPlay_TestCuckoo.mp3</i> file to that folder.
Example: D:\SlimData\SBPlay
2. Copy the <i>SBPLay.vb</i> file to <HOMESEERFOLDER>\Scripts
NOTE: Homeseerfolder is typically --> C:\Program Files\HomeSeer HS<VERSION>
3. Open SBPlay.vb in Notepad (or another editor) and make sure that the path to the SBPlay_Silence.mp3 file is the same as the path created in step 1 (as highlighted in the image with a red box).
Image

---------------------------------------
Usage
---------------------------------------
1. Create an Event in Homeseer with an "Run Script" Action
2. Select the "SBPlay.vb" script
3. Fill in at "Optional parameters":("Main","<IPADDRESS>;<AUDIOFILE>")

NOTE: The audiofile is the path to the audiofile on the local Squeezebox Server. For example: D:\SlimData\SBPLay\SBPlay_TestCuckoo.mp3

---------------------------------------
Mandatory Parameters
---------------------------------------
<IPADDRESS> IPAddress of the Squeezebox host (Use "localhost" or "127.0.0.1" if the Squeezebox Server is installed on the same machine as HomeSeer)
<AUDIOFILE> Path to the .MP3 file on the Squeezecenter host

---------------------------------------
Optional Parameters
---------------------------------------
WAKEUP Will force devices to Power On if they are currently in Off state.

---------------------------------------
Example
---------------------------------------
1. Play .MP3 on all Squeezeserver connected and powered on devices:
SBPlay.vb("Main","localhost", "D:\SlimData\SBPLay\SBPlay_TestCuckoo.mp3")


2. Play .MP3 on all Squeezeserver connected devices and power on devices which are currrently switched off:
SBPlay.vb("Main","localhost", "D:\SlimData\SBPLay\SBPlay_TestCuckoo.mp3", WAKEUP)


---------------------------------------
Usage Scenario's
---------------------------------------
- Notify when the dryer is finished
- Notify when the washingmachine is finished
- Post a reply with your cool usage scenario's

---------------------------------------
DEBUG INFORMATION
---------------------------------------
You can switch on debugging from the SBPLay.vb file in the settings section. Set the line <b>bDebug = False</b> to <b>bDebug = True</b>. Debug information will be logged in the HomeSeer logfile.

Error's will also be reported in the HomeSeer log regarding of the debug setting.

----------------------------------------
Other
----------------------------------------
SBPlay_TestCuckoo.mp3 is included as test mp3 file. It is not required for the functionality of the script.

SBPlay_Silence.mp3 is a required file. Without this file the script will fail. This file is used to generate silence as soon as the announcement is finished so the script knows that it's done. Do not alter or replace it.

----------------------------------------
Features
----------------------------------------
- Leaves the current playlist in place ;
The script will insert the announcement mp3, but will remove them as soon as it is finished.
- Resumes the song that was playing at the position where it was;
Besides the announcement, you never know that a script has run [:p]
- Can wakeup powered of devices;
This is optional but possible.
- Works faster than saving the playlist and resuming it;
Temporarily saving the current playlist costs time (2-4 seconds depending on the speed of the Squeezebox Server). This method is not used, which made it a long developement process.
- Intelligent CLI response checking is implemented;
Unfortunatelly telnet is used as interface. Unfortunatelly, because that slows things down, because the script has to wait and check pro-activly for the response on given commands before continuing. To counter this effect the read function does not use fixed lenghty sleepvalues. For details review the SBPlay.vb script.

----------------------------------------
Testing
----------------------------------------
I've only tested the script without the Wakeup parameter. So let me know if the wakeup parameter works.
This script is only tested on a Squeezebox Server and therefor not on SqueezeCenter. This should not be an issue but you never know. Also I've tested it only using SqueezePlay and not with other (physical) devices.

----------------------------------------
Known issues
----------------------------------------
During extensive testing it happened that the resumed song played on half the tempo. While this is a weird and funny thing, I think it is because of number of requists I made to the Squeezebox Server or because I used SqueezePlay, which lost the connection a few times.

----------------------------------------
FAQ / Troubleshooting / Q&A
----------------------------------------
Q: When I run the script nothing happens on my Squeezbox Server connected devices?
A: 1. Make sure they are powered on or use the WAKEUP switch.
2. Check the playlist (with the webserver for example -> http://<IPADDRESS_OF_SQUEEZEBOXSERVER>:9000) to see if your mp3 is being queued as soon as the script runs. If not than:
A. The path you entered for the mp3 is not accessible from the Squeezebox server (make sure the mp3's are on the local Squeezebox Server and the path reflects to the localpath e.g. D:\SlimData\SBPlay\myannouncement.mp3).
B. The mp3 is corrupted. Try starting it from mediaplayer to check.
Q: There is a strange file in my playlist with the title Announcement Finished, what is happening?
A: This file will be queued to prevent that the next song will be played when the announcement is finished and is used by the script to check is the announcement is finished. Normally the script is so fast that this file will be played for no more then 1 second. If this file keeps playing (it is 30 seconds of silence), then there is a problem with the script, your announcement mp3, or the parameters you've used.
Q: How do I get MP3's for announcements?
A: Good question.
1. Record them with your mic
2. Make one using HSSpeak (do not have exact details, maybe someone will post them)
3. Extend the script with text2speech functionality
(that's right...this is very cool and possible, I just don't have the time anymore to do this)
3. Use another text2speech package to create them
Q: Can I alter the script.
A: Yes, you can [:o)]. <b>There is one condition:</b> <u>You have to post it here</u>, with a good description of your changes/extensions(and also in the .vb file). This way everyone will profit from it.

Download SBPlay:
domoticaforum.eu/uploaded/tailwind/2009 ... lay0.1.zip
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

Re: [HSSCRIPT] SBPLay - Play announcement MP3's

Post by Snelvuur »

To revive a old thread, have you made any improvements on the script over time?

I've just downloaded and it works like a charm though.

I also got the squeezebox plugin from homeseer, in there you can say the tts functions and also the speak/announce volume. This might be handy for you too.

But hey, it works i am fine with that :)

p.s. it works on my linux squeezeserver just fine, just change path to /blabla/sounds/something.mp3 instead of d:\somewhere paths.
p.p.s is it normal it spams the log so much in debug mode? i would assume that once run it would "end"
// Erik (binkey.nl)
Post Reply

Return to “Homeseer Scripts Forum”