PBX Services

The Services can be accessed by dialing 9000.

These services are automatically created and uploaded onto the PBX when it is connected to the internet.

RSGB News - Option 1

The latest podcast of the RSGB news is loaded onto the system every Sunday morning. This can be listened to throughout the week. This can also be accessed online by visiting https://rsgb.org/main/gb2rs/gb2rs-podcast/

 

Severe Weather Warnings - Option 2

These are provided by the Met Office and be viewed online at https://www.metoffice.gov.uk/weather/warnings-and-advice/uk-warnings.

They are refreshed every hour for any updates.

 

How are these created

Services 1 - RSGB News

This is transferred from the podcast site XML feed via a PYTHON script and the mp3 file is converted into a wav file (8k).

This is executed by a CRON task every Sunday morning.

# gets the latest rsgb news mp3
# SGreen JND Solutions
# G4EKM
# 23/2/2021
import requests
import xml.etree.ElementTree as ET
from pydub import AudioSegment
podcasturl = 'https://feed.podbean.com/gb2rs/feed.xml'
podcast = requests.get(podcasturl, allow_redirects=True)
open('rsgb.xml', 'wb').write(podcast.content)
root = ET.parse('rsgb.xml').getroot()
for type_tag in root.findall('channel/item/enclosure'):
    latestfileurl = type_tag.get('url')
    break

print(latestfileurl)
print "downloading mp3 file"
latestpodcast = requests.get(latestfileurl, allow_redirects=True)
open('news.mp3', 'wb').write(latestpodcast.content)
print "converting to .wav"

sound = AudioSegment.from_mp3("news.mp3")
sound = sound.set_frame_rate(8000)
sound.export("/var/lib/asterisk/sounds/en/custom/news.wav", format="wav")

 

 

Services 2 - Severe Weather Warning

This is transferred from a RSS feed from the metoffice.gov.uk website and processed by a CRON task every hour

# gets the latest weather warnings fro metoffice.gov.uk
# SGreen JND Solutions
# G4EKM
# 24/2/2021
import requests
import xml.etree.ElementTree as ET
from gtts import gTTS
from pydub import AudioSegment
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
feedurl = 'http://www.metoffice.gov.uk/public/data/PWSCache/WarningsRSS/Region/UK'
weatherfeed = requests.get(feedurl, allow_redirects=True)

open('weatherwarning.xml', 'wb').write(weatherfeed.content)
root = ET.parse('weatherwarning.xml').getroot()

maindesc=root[0].find('description').text
pubdate=root[0].find('pubDate').text
print(maindesc)
print(pubdate)
areatext = ""
for area_item in root.findall('channel/item'):
        title = area_item.find('title').text
        desc = area_item.find('description').text
        #print(title)
        print(desc)
        areatext =areatext + desc + "...... "
outtext=maindesc + ".......Published  " + pubdate + "...... " + areatext
print(outtext)
tts = gTTS(text = outtext, lang='en')
tts.save("weather.mp3")
print "converting to .wav"

sound = AudioSegment.from_mp3("weather.mp3")
sound = sound.set_frame_rate(8000)
sound.export("/var/lib/asterisk/sounds/en/custom/weather.wav", format="wav")