Time & Temp Announcer Script


(Don) #1

I read on another website someone wrote a Asterisk script that would say the time and temperature with the Pat Fleet recorded prompts for Asterisk

I would like to recreate that script if you could let me know how to set that up that would be great.

Thanks


(Jared Busch) #2

This post was flagged by the community and is temporarily hidden.


(Simon Telephonics) #3

Looks like you have been working on this project a long time!

https://community.freepbx.org/t/time-temp-with-weather-forecast-announcer/62477

No offense meant but if you read about it on another web site then why not use what they wrote there (and maybe post a link to it here for others who are interested).


(Jared Busch) #4

This post was flagged by the community and is temporarily hidden.


(Don) #5

I tried to post the link but it would not let me.

I tried to contact the person who created the script but did not get a response so I was wanting to recreate it.

[you should be able to post links now - mod]


(Don) #6

https://www.themagiccafe.com/forums/viewtopic.php?topic=497770


(Simon Telephonics) #7

I think the building blocks are the following, each of which you would have to research a bit and implement:

  • get a Pat Fleet sound library and upload it to your FreePBX server in the sounds location
  • write a bash or php script to return current time (easy, from server time) and temperature (harder, from internet source)
  • use those numbers in custom asterisk dial plan which plays the sound files you uploaded
  • point to the custom dial plan with an internal extension or a DID/Inbound Route

TMTOWTDI.


#8

Add to that recipe

api.weather.gov # to get the weather
jq #to parse that data
TTS from google , amazon, whoever


(Don) #9

I have already uploaded the Pat Fleet sound library. I need help writing the bash or php script to get the time and temp the URL I would like to use is https://w1.weather.gov/xml/current_obs/display.php?stid=KDKK.


#10

no need to scrape they have an API

https://weather-gov.github.io/api/general-faqs

Get the lat/lon from your site snd plug it into that


#11

Follow that and

https://api.weather.gov/gridpoints/BUF/23,26/forecast


(Don) #12

Ok but I want to use the Pat Fleet voice library not TTS.


#13

Ask her to say

curl “https://api.weather.gov/gridpoints/BUF/23,26/forecast”|jq -r ‘[[.[]]|.[3].periods[0].detailedForecast]’

Or splice together her words and the interpreted values from the api

did Pat do all the phrases in /var/lib/asterisk/sounds/en/wx because they will be useful


(Don) #14

I need her to say

ETC time is (TIME) temperature (TEMP) Thank you for calling ETC.

Yes she did all the WX sounds.


#15

Temp is

|jq  '[.[]]|.[3].periods[0].temperature'

For time extract piecemeal hours minutes am/pm whatever with strftimea()

https://www.voip-info.org/asterisk-func-strftime/


(Don) #16

So how do I set that up in FreePBX.


(Simon Telephonics) #17

by this I meant use sources other than this forum to help fill in the knowledge gaps you have. Especially for tasks out of scope of this forum such as writing bash scripts to fetch data from the internet.


(TheJames) #18

@lgaetz is a bit of a dialplan demigod and has done some write-ups such as.
https://community.freepbx.org/t/hooking-for-fun-and-income/57718

It may be worth looking at that and possibly searching the forums for from-internal-custom

Also helpful
https://wiki.asterisk.org/wiki/display/AST/Contexts%2C+Extensions%2C+and+Priorities

http://nerdvittles.com/?p=136 may also be useful as a reference point but it uses TTS

https://www.asterisksounds.org/en/sounds has a listing of standard sound files.

search for weather
https://www.asterisksounds.org/en/sounds?s=weather

side note… If you use the standard sounds you can seamlessly use custom prompts from Allison (the voice of Asterisk) https://www.theivrvoice.com/


(Lorne Gaetz) #19

@don4444

There are several projects/examples that read back time/weather to the caller floating around on the 'net. Most are open source so you can freely rip them off borrow from them with attribution. If you want to learn how to add custom dialplan to a FreePBX system, you might want to start here
https://wiki.freepbx.org/display/FDT/FreePBX+Dialplan+Customization
The actual content won’t help you directly, but the concepts for Custom Destinations will.

The community is here to provide pointers when you get stuck, not do it for you.

Also there is the speaking clock built into FreePBX feature codes. If you want to see how that is done you can search the file /etc/asterisk/extensions_additional.conf for [app-speakingclock]


#20

The curt answer, RTFM :slight_smile: