'OPTION _EXPLICIT
Weather = GetWeather
'eSpeak Weather
TTS FormatForTTS(Weather)
URLFile = "weatherrequest"
state
= LCASE$(GetStateFromZipCode
) URL
= "https://tgftp.nws.noaa.gov/data/forecasts/zone/" + state
+ "/" + CrossRefZoneState
(UCASE$(state
), GetCountyFromZipCode
) + ".txt" a% = API_request(URL, URLFile)
GetWeather = ""
weather
= String.Remove
(weather
, "$$") GetWeather = weather
zone
= MID$(zones
, INSTR(zones
, state
+ "Z")) zone
= MID$(zone
, INSTR(zone
, county
) - 7, 6) CrossRefZoneState
= LCASE$(zone
) CrossRefZoneState = ""
URLFile = "county"
URL = "https://us-zipcode.api.smartystreets.com/lookup?auth-id=YOURAUTHIDHERE&auth-token=YOURAUTHTOKENHERE&zipcode=" + GetLocationVIAip
a% = API_request(URL, URLFile)
GetCountyFromZipCode = ""
county
= MID$(county
, INSTR(county
, "county_name") + 14) GetCountyFromZipCode = county
URLFile = "statebyzip"
URL = "https://us-zipcode.api.smartystreets.com/lookup?auth-id=YOURAUTHIDHERE&auth-token=YOURAUTHTOKENHERE&zipcode=" + GetLocationVIAip
a% = API_request(URL, URLFile)
GetStateFromZipCode = ""
state
= MID$(state
, INSTR(state
, "state_abbreviation") + 21) GetStateFromZipCode = state
URLFile = "location"
URL = "https://geo.ipify.org/api/v1?apiKey=YOURAPIKEYHERE&ipAddress=" + GetPublicIP
a% = API_request(URL, URLFile)
GetLocationVIAip = ""
location
= MID$(location
, INSTR(location
, "postalCode") + 13) GetLocationVIAip = location
URLFile = "publicip"
URL = "https://api.ipify.org/"
a% = API_request(URL, URLFile)
GetPublicIP = ""
GetPublicIP = publicip
c = ""
r$ = a
r$ = a
API_request
= URLDownloadToFileA
(0, URL
+ CHR$(0), File
+ CHR$(0), 0, 0)
Filename
= "espeak.exe -v en " + CHR$(34) + lines$
+ CHR$(34) x
= WinExec
(Filename$
+ CHR$(0), 0)
x
= WinExec
("voice -r 2 -d " + lines
+ CHR$(0), 0)
lines
= MID$(lines
, INSTR(lines
, "OVERNIGHT")) lines
= String.Replace
(lines
, "wind", "wend") lines
= String.Replace
(lines
, "mph", "miles per hour") lines
= String.Replace
(lines
, "thunderstorms", "thunnderstorms") FormatForTTS = lines