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
# 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')

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
# 24/2/2021
import requests
import xml.etree.ElementTree as ET
from gtts import gTTS
from pydub import AudioSegment
import urllib3
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()

areatext = ""
for area_item in root.findall('channel/item'):
        title = area_item.find('title').text
        desc = area_item.find('description').text
        areatext =areatext + desc + "...... "
outtext=maindesc + ".......Published  " + pubdate + "...... " + areatext
tts = gTTS(text = outtext, lang='en')
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")