<commit_before>import pyaudio
import struct
import math
import wave
import urllib  
import urllib2 
import os


class Microphone:

    def rms(self,frame):
        count = len(frame)/2
        format = "%dh"%(count)
        shorts = struct.unpack( format, frame )
        sum_squares = 0.0
        for sample in shorts:
            n = sample * (1.0/32768.0)
            sum_squares += n*n
        rms = math.pow(sum_squares/count,0.5);
        return rms * 1000

    def passiveListen(self,persona):

        CHUNK = 8192; RATE = 44100; THRESHOLD = 50; LISTEN_TIME = 5

        didDetect = False
        
        # prepare recording stream
        p = pyaudio.PyAudio()
        stream = p.open(format=FORMAT, channels = 1, rate = RATE, input = True, input_device_index = 0, frames_per_buffer = CHUNK)

        # stores the audio data
        all =[]

        # starts passive listening for disturbances 
        for i in range(0, RATE / CHUNK * LISTEN_TIME):<commit_msg>more changes<commit_after>import pyaudio
import struct
import math
import wave
import urllib  
import urllib2 
import os


class Microphone:

    def rms(self,frame):
        count = len(frame)/2
        format = "%dh"%(count)
        shorts = struct.unpack( format, frame )
        sum_squares = 0.0
        for sample in shorts:
            n = sample * (1.0/32768.0)
            sum_squares += n*n
        rms = math.pow(sum_squares/count,0.5);
        return rms * 1000

    def passiveListen(self,persona):

        CHUNK = 1024
        FORMAT = pyaudio.paInt16
        CHANNELS = 1
        RATE = 16000
        RECORD_SECONDS = 5

        didDetect = False
        
        # prepare recording stream
        p = pyaudio.PyAudio()
        stream = p.open(format=FORMAT, channels = 1, rate = RATE, input = True, input_device_index = 0, frames_per_buffer = CHUNK)

        # stores the audio data
        all =[]

        # starts passive listening for disturbances 
        for i in range(0, RATE / CHUNK * LISTEN_TIME):
{'fraction_non_alphanumeric': 0.08867735470941884, 'fraction_numerical': 0.03356713426853707, 'mean_word_length': 2.0535168195718656, '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': '291391', 'n_tokens_mistral': 689, 'n_tokens_neox': 619, 'n_words': 178}