Online Text to Audio File?

Hey, I have a script to access a weather forecast that instead of having it speak the text I’d like to convert it to
an audio file. I’ve been able to do it with text I have generated on my machine locally but I haven’t figured out how to have this script do the same:

(*
Installation instructions:
Connect to http://weather.weatherbug.com
find your location and get the current report
Then, under “Your forecast for…” click the link labeled “more”
When you get “Your Detailed Forecast” copy the complete URL and (unless you live in Berkeley, CA)
replace the URL in the command “set myURL” below.
Finally, set placename to whatever you want the announcement to say.
*)

set myURL to “http://weather.weatherbug.com/MT/Kalispell-weather/local-forecast/detailed-forecast.html?zcode=z6286
set placename to "morningview lodge in Kalaspel Montana "
tell application “URL Access Scripting”
set my_output_file to (path to temporary items folder as string) & “WeatherBug.html”
download myURL to my_output_file replacing yes
end tell

→ Extract forecast
set str to read_parse(my_output_file, “<div class="wXfore-day">”, “<div class="wXclearfloats">”, true, 1)
set str to remove_markup(str)

→ Make speech a bit nicer
set newlineChar to ASCII character 10
set returnChar to ASCII character 13
set str to replace_chars(str, newlineChar, “”)
set str to replace_chars(str, returnChar, “”)
set str to replace_chars(str, “mph”, “miles per hour”)
set str to replace_chars(str, “10s”, “teens”)
set str to replace_chars(str, “20s”, “twenties”)
set str to replace_chars(str, “30s”, “thirties”)
set str to replace_chars(str, “40s”, “forties”)
set str to replace_chars(str, “50s”, “fifties”)
set str to replace_chars(str, “60s”, “sixties”)
set str to replace_chars(str, “70s”, “seventies”)
set str to replace_chars(str, “80s”, “eighties”)
set str to replace_chars(str, “90s”, “nineties”)
set str to replace_chars(str, “100s”, “hundreds”)
set str to replace_chars(str, “110s”, “hundred-and-tens”)
set str to replace_chars(str, “120s”, “hundred-and-twenties”)
set str to replace_chars(str, “130s”, “hundred-and-thirties”)
set str to replace_chars(str, “fog”, “fawgg”)
set str to replace_chars(str, “&deg”, " degrees")
set str to replace_chars(str, “2010”, “2010:”)
set str to replace_chars(str, “Lo:”, “Low:”)
set str to replace_chars(str, “;”, “:”)
set str to replace_chars(str, “.”, “,!”)

set weatherReport to "The weather for " & placename & ": " & str

say weatherReport

on read_parse(this_file, opening_tag, closing_tag, contents_only, num_matches)
try
set this_file to this_file as text
set this_file to open for access file this_file
set the combined_results to “”
set the open_tag to “”
set finished to false
set matched to 0
repeat while not finished
read this_file before “<” – start of a tag
set this_tag to read this_file until “>” – end of a tag
– to make up for a bug in the “read before” command
if this_tag does not start with “<” then ¬
set this_tag to (“<” & this_tag) as string
– EXAMINE THE TAG
if this_tag begins with the opening_tag then
–store the complete tag, not just the search string
set the open_tag to this_tag
– check for single tag indicator
if the closing_tag is “” then
if the combined_results is “” then
set the combined_results to the combined_results & the open_tag
else
set the combined_results to the combined_results & return & the open_tag
end if
else
– reset the text buffer
set the text_buffer to “”
– extract the contents between the open and close tags
repeat
set the text_buffer to the text_buffer & (read this_file before “<”) – start of a tag
set the tag_buffer to read this_file until “>” – end of a tag
– to make up for a bug in the “read before” command
if the tag_buffer does not start with “<” then set the tag_buffer to (“<” & the tag_buffer) as string
– check for the closing tag
if the tag_buffer is the closing_tag then
set matched to matched + 1
if matched ≥ num_matches then set finished to true
if contents_only is false then
set the text_buffer to the open_tag & the text_buffer & the tag_buffer
end if
if the combined_results is “” then
set the combined_results to the combined_results & the text_buffer
else
set the combined_results to the combined_results & return & the text_buffer
end if

                        exit repeat
                    else
                        set the text_buffer to the text_buffer & the tag_buffer
                    end if
                end repeat
            end if
        end if
    end repeat
    close access this_file
on error error_msg number error_num
    try
        close access this_file
    end try
    if error_num is not -39 then return false
end try
return the combined_results

end read_parse

on remove_markup(this_text)
set copy_flag to true
set the clean_text to “”
repeat with this_char in this_text
set this_char to the contents of this_char
if this_char is “<” then
set the copy_flag to false
else if this_char is “>” then
set the copy_flag to true
else if the copy_flag is true then
set the clean_text to the clean_text & this_char as string
end if
end repeat
return the clean_text
end remove_markup

on replace_chars(this_text, search_string, replacement_string)
set AppleScript’s text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript’s text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript’s text item delimiters to “”
return this_text

I was using this bit of code, adapted from my other script that does work, trying to insert/adapt it
into this one.

say this_file saving to “/Users/TV/Music/iTunes/Indigo/Indigo Audio/weather_forecast.aiff”

Really appreciate any thoughts on if and how this could be done.

Thanks,

Carl