<commit_before>__author__ = 'marijn'

from pprint import pprint
import logging
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)

from receiver import Receiver

def main():
    log.info("Starting")
    receiver = Receiver("../ga_config.json")
    receiver.connect_goal_sources()
    pprint(receiver.get_data())
    log.info("Ending")

<commit_msg>Added audio output and threading scafolding.<commit_after>__author__ = 'marijn'

from pprint import pprint
import logging
import time
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)

from receiver import Receiver


def main():
    log.info("Starting")
    receiver = Receiver("../ga_config.json")
    receiver.connect_goal_sources()
#    pprint(receiver.get_data())
    expresor = Expressor()
    try:
        log.info("first event")
        expresor.event_alert()
        time.sleep(1)
        log.info("second event")
        expresor.event_alert()
        for c in range(10):
            log.info("%d Sleeping", c)
            time.sleep(1)
    finally:
        expresor.stop()
    log.info("Ending")


import pykka
from pydub import AudioSegment, playback


class Expressor(object):
    def __init__(self):
        self._audio = AudioOutput.start()
    def event_alert(self):
        self._audio.tell({'do': 'play', 'sound_file': 'SeagullCall.wav'})
    def stop(self):
        self._audio.stop()

class AudioOutput(pykka.ThreadingActor):
    def on_receive(self, message):
        fn = "../sounds/%s" % message['sound_file']
        audio = AudioSegment.from_wav(fn)
        log.info("Pre play call")
        playback.play(audio)
        log.info("Post play call")
{'fraction_non_alphanumeric': 0.12589928057553956, 'fraction_numerical': 0.002398081534772182, 'mean_word_length': 3.2253164556962024, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6470400', 'n_tokens_mistral': 534, 'n_tokens_neox': 532, 'n_words': 112}