<commit_before>#!/usr/bin/env python

from __future__ import print_function

import numpy as np
from scipy.io import wavfile

import concept

def run_ana(data, fs, first_sample, length, freq):
    signal = data[first_sample:first_sample + length]
    tmp = list(concept.analyse_note(signal, fs, freq, 10))
    x1 = np.array([i[0] for i in tmp])
    b1 = np.array([i[1] for i in tmp])
    p1 = np.array([i[2] for i in tmp])
    return x1, b1, p1

def run():
    recording = 'data/11-oktave-4.wav'
    first_sample = 5130082
    freq = 526.
    length = 2**13
    
    result = dict()
    
    fs, data = wavfile.read(recording)
    result[first_sample] = run_ana(data, fs, first_sample, length, freq)

    for sample in range(first_sample - 9*fs, first_sample, 2**14):
        result[sample] = run_ana(data, fs, sample, length, freq)

    for k, v in sorted(result.items()):
        x1, b1, p1 = v
        line = list()
        for b, p in zip(b1, p1):
            line.append(b)
            line.append(p)
        print(k, *line)

if __name__ == '__main__':
    run()<commit_msg>continued the attack analysis<commit_after>#!/usr/bin/env python

from __future__ import print_function

import numpy as np
from scipy.io import wavfile

import concept

def run():
    recording = 'data/11-oktave-4.wav'
    first_sample = 5130082
    freq = 526.
    length = 2**13
    
    fs, data = wavfile.read(recording)

    result = dict()

    signal = data[first_sample:first_sample + length]
    tmp = list(concept.analyse_note(signal, fs, freq, 10))
    x1 = np.array([i[0] for i in tmp])
    b1 = np.array([i[1] for i in tmp])
    p1 = np.array([i[2] for i in tmp])
    result[first_sample] = p1

    for sample in range(first_sample - 3*fs, first_sample + 2*fs, 2**10):
        signal = data[sample:sample + length]
        spec = concept.decibel(concept.windowed_spectrum(signal))
        result[sample] = spec[b1]

    for k, v in sorted(result.items()):
        print(1.*k/fs, *v)

if __name__ == '__main__':
    run()
{'fraction_non_alphanumeric': 0.13164431197218082, 'fraction_numerical': 0.03378042722305018, 'mean_word_length': 2.828897338403042, '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': '586709', 'n_tokens_mistral': 782, 'n_tokens_neox': 734, 'n_words': 198}