import numpy as np


import scipy.signal as signal
import soundfile
import pandas as pd


results = np.load('annot_pitch.npy',allow_pickle=True).item()



all_time=[]
all_freq=[]
df = []

for key, value in results.items():
    print(key)
    #print(value)
    f, t, sxx = signal.spectrogram(np.random.normal(0,1,200000), nfft=1024//2, noverlap=1000//2, fs=22050, nperseg=1024//2)
    y, x = np.where(value)
    times, freqs = t[x], f[y]
    all_time.append(times)
    all_freq.append(freqs)
    rr={'voc':key,"time":times,"freq":freqs}
    df.append(rr)
df = pd.DataFrame.from_dict(df)

df.to_pickle("result_call.pkl")
