<commit_before>#!/usr/bin/python
import time
import random
import sys
import alsaaudio
import json
import requests
import os
import socket
from collections import OrderedDict

WHOAMI = socket.gethostname()
WHATAMI = os.path.basename(__file__).replace(".py", "")

#m = alsaaudio.Mixer('PCM')
#current_volume = m.getvolume() # Get the current Volume
#print("Cur Vol: %s " % current_volume)
#m.setvolume(100) # Set the volume to 70%.
#current_volume = m.getvolume() # Get the current Volume
#print("Cur Vol: %s " % current_volume)

hbinterval = 30
lasthb = 0


def main():
    logevent("startup", "startup", "Just started and ready to run")

    global lasthb
    global hbinterval

    sounds = [0, 0, 0]
    channels = 2
    rate = 44100
    size = 1024

#    out_stream = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, alsaaudio.PCM_NORMAL, 'default')
#    out_stream.setformat(alsaaudio.PCM_FORMAT_S16_LE)
#    out_stream.setchannels(channels)
#    out_stream.setrate(rate)
#    out_stream.setperiodsize(size)


    soundfiles = ['/home/pi/spencer_young.wav', '/home/pi/spencer2.wav', '/home/pi/spencer3.wav']
    soundblobs = []
    for sf in soundfiles:
        f = open(sf, 'rb')
        u = f.read()
        f.close()
        soundblobs.append(u)
        u = None


    while True:
        out_stream = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, alsaaudio.PCM_NORMAL, 'default')
        out_stream.setformat(alsaaudio.PCM_FORMAT_S16_LE)
        out_stream.setchannels(channels)
        out_stream.setrate(rate)
        out_stream.setperiodsize(size)


        #curfile = random.choice(soundfiles)
        curblob = random.choice(soundblobs)
        curtime = int(time.time())
        if curtime - lasthb > hbinterval:
            logevent("heartbeat", "Working", "Childhood room up and running")
            lasthb = curtime
#        curstream = open(curfile, "rb")
        data = curblob[0:size]
        curpos = size
#        data = curstream.read(size)
        while data:
            out_stream.write(data)
            data = curblob[curpos:size]
            curpos = curpos + size
            #curstream.read(size)
            if len(data) == size:
                pass
            else:
                out_stream.write(data)
                data = 0
#        curstream.close()
        try:
            outstream.close()<commit_msg>Update childhood<commit_after>#!/usr/bin/python
import time
import random
import sys
import alsaaudio
import json
import requests
import os
import socket
from collections import OrderedDict

WHOAMI = socket.gethostname()
WHATAMI = os.path.basename(__file__).replace(".py", "")

#m = alsaaudio.Mixer('PCM')
#current_volume = m.getvolume() # Get the current Volume
#print("Cur Vol: %s " % current_volume)
#m.setvolume(100) # Set the volume to 70%.
#current_volume = m.getvolume() # Get the current Volume
#print("Cur Vol: %s " % current_volume)

hbinterval = 30
lasthb = 0


def main():
    logevent("startup", "startup", "Just started and ready to run")

    global lasthb
    global hbinterval

    sounds = [0, 0, 0]
    channels = 2
    rate = 44100
    size = 1024

    out_stream = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, alsaaudio.PCM_NORMAL, 'default')
    out_stream.setformat(alsaaudio.PCM_FORMAT_S16_LE)
    out_stream.setchannels(channels)
    out_stream.setrate(rate)
    out_stream.setperiodsize(size)


    soundfiles = ['/home/pi/spencer_young.wav', '/home/pi/spencer2.wav', '/home/pi/spencer3.wav']
    soundblobs = []
    for sf in soundfiles:
        f = open(sf, 'rb')
        u = f.read()
        f.close()
        soundblobs.append(u)
        u = None


    while True:
#        out_stream = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, alsaaudio.PCM_NORMAL, 'default')
#        out_stream.setformat(alsaaudio.PCM_FORMAT_S16_LE)
#        out_stream.setchannels(channels)
#        out_stream.setrate(rate)
#        out_stream.setperiodsize(size)


        #curfile = random.choice(soundfiles)
        curblob = random.choice(soundblobs)
        curtime = int(time.time())
        if curtime - lasthb > hbinterval:
            logevent("heartbeat", "Working", "Childhood room up and running")
            lasthb = curtime
#        curstream = open(curfile, "rb")
        data = curblob[0:size]
        curpos = size
#        data = curstream.read(size)
        while data:
            out_stream.write(data)
            data = curblob[curpos:size]
            curpos = curpos + size
            #curstream.read(size)
            if len(data) == size:
                pass
            else:
                out_stream.write(data)
                data = 0
#        curstream.close()
        try:
            outstream.close()
{'fraction_non_alphanumeric': 0.11370950439819781, 'fraction_numerical': 0.012443681613387684, 'mean_word_length': 2.515837104072398, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4082526', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1502, 'n_words': 330}