I hacked your plug-in to play a chime prior to a TTS announcement. The reason is simple: most people will miss the first few syllables of a phrase if they are actively doing something else. By adding a chime, attention is grabbed and curiosity is keeping the focus. Here's what I changed, feel free to turn it into a feature if you'd like. I also changed your sleeping delays as 1.0 second is quite long. 0.3 is just about right.
Starting from line 2043
- Code: Select all
while count < 5 and success == 0:
try:
if "mp3" in s_announcement:
audio = MP3("./" + s_announcement)
elif "aiff" in s_announcement:
audio = AIFF("./" + s_announcement)
chime = MP3("./" + "Chime.mp3")
success = 1
except:
self.plugin.sleep(0.5)
count = count + 1
if success == 1:
playChime = 1;
if playChime == 1:
self.SOAPSend (zoneIP, "/MediaRenderer", "/AVTransport", "SetAVTransportURI", "<CurrentURI>http://" +
self.HTTPServer + ":" + self.HTTPStreamingPort + "/" + "Chime.mp3" +
"</CurrentURI><CurrentURIMetaData></CurrentURIMetaData>")
# turn off queue repeat
self.actionDirect (PA(GM.id, {'setting':0}), "Q_Repeat")
self.plugin.sleep(0.3)
self.actionDirect (PA(GM.id), "Play")
self.plugin.sleep( chime.info.length)
indigo.server.log("Announcement Length: %s" % audio.info.length)
self.SOAPSend (zoneIP, "/MediaRenderer", "/AVTransport", "SetAVTransportURI", "<CurrentURI>http://" +
self.HTTPServer + ":" + self.HTTPStreamingPort + "/" + s_announcement +
"</CurrentURI><CurrentURIMetaData></CurrentURIMetaData>")
# turn off queue repeat
self.actionDirect (PA(GM.id, {'setting':0}), "Q_Repeat")
self.plugin.sleep(0.3)
self.actionDirect (PA(GM.id), "Play")
self.plugin.sleep(tts_delay + audio.info.length)
else:
self.plugin.errorLog("Unable to read MP3 file. Announcement aborted.")