From 11f02174a7ef519ea79f26cc8bfff34f118d4dbc Mon Sep 17 00:00:00 2001 From: acastro Date: Mon, 19 Nov 2018 15:41:51 +0000 Subject: [PATCH] adding announcer --- announcements.py | 27 +++++++++++++++++++++++++++ announcer.json | 11 +++++++++++ 2 files changed, 38 insertions(+) create mode 100755 announcements.py create mode 100644 announcer.json diff --git a/announcements.py b/announcements.py new file mode 100755 index 0000000..1757768 --- /dev/null +++ b/announcements.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import json, random, os +from pprint import pprint +from time import sleep + +# open announcer.json files +pwd = os.path.dirname( os.path.realpath(__file__) ) + "/" +announcer_f = open(pwd + "announcer.json", "r").read() +announcer = json.loads(announcer_f) + +# print(announcer) + +# ANNOUNCER PART +# msg = random.choice( announcer['messages'] ) #chooing a random annoncement. + + +sound_dir = pwd + "Audio_recordings/Announcements/" +intro_sf = sound_dir + random.choice( announcer['introductions'] ) +msg_sf = sound_dir + random.choice( announcer['messages'] ) + +print(intro_sf, msg_sf) + + +#play audio +os.system('play -q "{}" gain 10 '.format(intro_sf) ) +sleep(random.randint(1,3)) +os.system('play -q "{}" gain 10 '.format(msg_sf) ) diff --git a/announcer.json b/announcer.json new file mode 100644 index 0000000..81e17c8 --- /dev/null +++ b/announcer.json @@ -0,0 +1,11 @@ +{ + + "introductions" : ["jingle_01.wav", "jingle_02.wav", "jingle_03.wav", "jingle_04.wav", "jingle_05.wav", "jingle_06.wav"], + + "messages" : [ + "announcement_msg_01.wav", + "announcement_msg_02.wav" + ] + + +} \ No newline at end of file