<commit_before>#!/usr/bin/env python
import numpy as np
import audio
import util, iir

delay = .005

def processOutput(output, loopback_Fs, loopback_Fc, upsample_factor, mask_noise):
    output = util.upsample(output, upsample_factor)
    output = (output * np.exp(1j * 2 * np.pi * np.arange(output.size) * loopback_Fc / loopback_Fs)).real
    output *= 1.0 / np.percentile(np.abs(output), 95)
    output = np.r_[output, np.zeros(int(.1*loopback_Fs))]
    if mask_noise is not None:
        if mask_noise.size > output.size:
            output = np.r_[output, np.zeros(mask_noise.size-output.size)]
        output[:mask_noise.size] += mask_noise[:output.size]
    delay_samples = int(delay*loopback_Fs)
    # delay one channel slightly relative to the other:
    # this breaks up the spatially-dependent frequency-correlated
    # nulls of our speaker array
    output = np.vstack((np.r_[np.zeros(delay_samples), output],
                        np.r_[output, np.zeros(delay_samples)])).T
    return output

def processInput(input, loopback_Fs, loopback_Fc, upsample_factor):
    input = input * np.exp(-1j * 2 * np.pi * np.arange(input.size) * loopback_Fc / loopback_Fs)
    input = iir.lowpass(.8/upsample_factor)(np.r_[np.zeros(6), input])[6::upsample_factor]
    return input

class InputProcessor:
    def __init__(self, Fs, Fc, upsample_factor):
        self.upsample_factor = upsample_factor
        self.order = 6<commit_msg>Added support for non-integer decimation factors<commit_after>#!/usr/bin/env python
import numpy as np
import audio
import util, iir

delay = .005

def processOutput(output, loopback_Fs, loopback_Fc, upsample_factor, mask_noise):
    output = util.upsample(output, upsample_factor)
    output = (output * np.exp(1j * 2 * np.pi * np.arange(output.size) * loopback_Fc / loopback_Fs)).real
    output *= 1.0 / np.percentile(np.abs(output), 95)
    output = np.r_[output, np.zeros(int(.1*loopback_Fs))]
    if mask_noise is not None:
        if mask_noise.size > output.size:
            output = np.r_[output, np.zeros(mask_noise.size-output.size)]
        output[:mask_noise.size] += mask_noise[:output.size]
    delay_samples = int(delay*loopback_Fs)
    # delay one channel slightly relative to the other:
    # this breaks up the spatially-dependent frequency-correlated
    # nulls of our speaker array
    output = np.vstack((np.r_[np.zeros(delay_samples), output],
                        np.r_[output, np.zeros(delay_samples)])).T
    return output

def processInput(input, loopback_Fs, loopback_Fc, upsample_factor):
    input = input * np.exp(-1j * 2 * np.pi * np.arange(input.size) * loopback_Fc / loopback_Fs)
    order = 6
    input = iir.lowpass(.8/upsample_factor, order=order)(np.r_[np.zeros(order), input])[order:]
    input = input[(np.arange(input.size/upsample_factor) * upsample_factor).astype(int)]
    return input

class InputProcessor:
    def __init__(self, Fs, Fc, upsample_factor):
        self.upsample_factor = upsample_factor
        self.order = 6
{'fraction_non_alphanumeric': 0.1213027583914922, 'fraction_numerical': 0.01030242605516783, 'mean_word_length': 3.5606060606060606, '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': '1760436', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1001, 'n_words': 224}