I do have squeezebox TTS working for some select scenes. Thank you for the posts and guidence on the forums. However, I was really craving for dynamic TTS based on weather conditions. I don’t have sonos and I wasn’t able to do it with luup and squeezebox. Nevertheless, I took a different approach and I’m sharing it for those who want to try. I resorted to VBscript. The code below was modified from a public post demonstrating (and teaching) scripting on TTS and weather.
Step 1: Install “SoundIt” by winkoppp [url=http://forum.micasaverde.com/index.php/topic,13029.msg96249.html#msg96249]http://forum.micasaverde.com/index.php/topic,13029.msg96249.html#msg96249[/url]
Step 2: Link the VBscript file to SoundIt. The following VBscript will get weather data from Yahoo and “speak it” (TTS) on the computer were SoundIt is installed (I have an XP box).
Step 3: Create a scene as desired to trigger the weather broadcast. (I trigger the “broadcast” via a light switch in my kitchen to hear the current weather. I have speakers over the Kitchen cabinet that are connected to the PC in the basement where SoundIt is installed).
You can modify the script to accommodate the weather location of your choice.
[code]Option Explicit
’
’ VBScript to retrieve current Internet weather from Yahoo and read it out
’
’ To find the appropriate RSS feed for your city,
’ use Weather Location Codes/IDs for Apple iPhone, Android Tablet, Linux Ubuntu to find the location code for your desired weather.
’ Replace the code in the URL below with your weather location code.
’
’ (CAXX0343 is Yahoo’s code for Ottawa; u=c means units are Celsius rather than Fahrenheit)
’
Dim WeatherRSS
WeatherRSS = “http://weather.yahooapis.com/forecastrss?p=CAXX0343&u=c”
’
’ Other variables
’
Dim WinHttpReq, XMLData, objXML, weatherCity, weatherCondition, currTemp, highTemp, lowTemp, WindChill, vHumidity, vVisibility, vSunrise, vSunset, vConditionTime
Dim Response
’
’ Fetch the RSS feed
’
Set WinHttpReq = CreateObject(“WinHttp.WinHttpRequest.5.1”)
’ Use the URL of the text file you wish to retrieve:
WinHttpReq.Open “GET”, WeatherRSS, False
WinHttpReq.Send
If (WinHttpReq.Status = 200) Then
XMLData = WinHttpReq.ResponseText
Set objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = "False"
objXML.loadXML(XMLData)
weatherCity = objXML.getElementsByTagName("yweather:location").item(0).attributes.getNamedItem("city").value
vConditionTime = objXML.getElementsByTagName("yweather:condition").item(0).attributes.getNamedItem("date").value
weatherCondition = objXML.getElementsByTagName("yweather:condition").item(0).attributes.getNamedItem("text").value
currTemp = objXML.getElementsByTagName("yweather:condition").item(0).attributes.getNamedItem("temp").value
highTemp = objXML.getElementsByTagName("yweather:forecast").item(0).attributes.getNamedItem("high").value
lowTemp = objXML.getElementsByTagName("yweather:forecast").item(0).attributes.getNamedItem("low").value
WindChill = objXML.getElementsByTagName("yweather:wind").item(0).attributes.getNamedItem("chill").value
vHumidity = objXML.getElementsByTagName("yweather:atmosphere").item(0).attributes.getNamedItem("humidity").value
vVisibility = objXML.getElementsByTagName("yweather:atmosphere").item(0).attributes.getNamedItem("visibility").value
vSunrise = objXML.getElementsByTagName("yweather:astronomy").item(0).attributes.getNamedItem("sunrise").value
vSunset = objXML.getElementsByTagName("yweather:astronomy").item(0).attributes.getNamedItem("sunset").value
' Edit this to suit your needs. Note that whenever you have 'in' immediately after a number,
' Microsoft.Speech expands it to "inches", so we put a comma before it.
Response = "You have trigged an automated weather announcement. Let me retrieve the current weather. This " & weatherCity & " weather information was obtained on " & vConditionTime & ". I'm reporting " & weatherCondition & " and with current temperature of " & currTemp & " degrees celsius. The reported windy chill today is " & WindChill & " degrees celsius. The reported humidity today is " & vHumidity & " percent. The reported visibility today is " & vVisibility & ". The expected high temperature is " & highTemp & " degrees celsius and the expected low temperature will be " & lowTemp & " degrees celsius. The sunrise for today is " & vSunrise & " and the sunset is " & vSunset & ". Have a nice day!"
else
’ Problem reading weather from the server
Response = “Sorry, I can’t predict the weather today.”
end if
’ Uncomment the next line to see a message box with the response
’ WScript.Echo Response
’ Now send the response to Windows TTS
Dim objVoice
Set objVoice = CreateObject(“SAPI.SpVoice”)
objVoice.Speak Response[/code]