<jupyter_start><jupyter_text>リアルタイム的に読み込み<jupyter_code>blocks = []
for i in range(0, len(y) - SR, HOP_LENGTH):
    blocks.append(y[i:i+SR])
specs = []
chromes = []

spec_sim = []
chromes_sim = []

BUF_NUM = 12

for b in blocks:
    y_harmonic, y_percussive = librosa.effects.hpss(b)

    C = np.average(librosa.feature.chroma_cens(y=y_harmonic, sr=sr), axis=1)
    D = np.average(librosa.amplitude_to_db(np.abs(librosa.stft(b)), ref=np.max), axis=1)[:512]

    C /= np.linalg.norm(C, ord=2)
    D /= np.linalg.norm(D, ord=2)

    specs.append(D)
    chromes.append(C)

    if len(specs) > BUF_NUM:
        s1 = np.average(np.dot(specs[-1], np.array(specs[-(BUF_NUM-1):-1]).T))
        spec_sim.append(s1)
    if len(chromes) > BUF_NUM*12:
        s2 = np.average(np.dot(chromes[-1], np.array(chromes[-(BUF_NUM-1):-1]).T))
        chromes_sim.append(s2)

plt.plot(spec_sim)
plt.plot(chromes_sim)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18506493506493507, 'fraction_numerical': 0.023809523809523808, 'mean_word_length': 3.7435897435897436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '170108', 'license': 'MIT', 'n_tokens_mistral': 456, 'n_tokens_neox': 429, 'n_words': 54, 'path': 'notebook/similarities.ipynb', 'repo_name': 'T-Sumida/music-change-point-detactor', 'size': '924'}