<jupyter_start><jupyter_text>Data needs to be in .wav formatIf there are two channels, average bothAudio values range from -32768 to 32768Sample rate (fs) typically 44.1KHz<jupyter_code># read in song
fs, data = wavfile.read(files[0])
# take average of two channels
data_sc = np.mean(data, axis=1)
# duration in sec
T = float(len(data))/fs
# time vector
time = np.arange(0, T, 1./fs)
# plot time series
fig = plt.figure()
plt.plot(time,data_sc)
plt.xlabel('Time [sec]')
plt.ylabel('Amplitude')
plt.show()
# short time fourier transform
f, t, Zxx = stft(data_sc, fs)
result = np.abs(Zxx)
# process results for clearer plots
maxdB = 32767.    # maximum possible value
result_db = 20.*np.log10(np.abs(result/maxdB)+1e-5)    # convert to dB
# negative values will be a problem?
result_db = np.clip(result_db, -40, 200)   # clip results
# plot spectogram
fig = plt.figure()
plt.pcolormesh(t, f, result_db)
plt.title('STFT Magnitude')
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.colorbar()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13872832369942195, 'fraction_numerical': 0.031791907514450865, 'mean_word_length': 5.076023391812866, 'pattern_counts': {'":': 0, '<': 5, '<?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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '131466', 'license': 'MIT', 'n_tokens_mistral': 423, 'n_tokens_neox': 386, 'n_words': 111, 'path': 'make_spectogram.ipynb', 'repo_name': 'mj-will/classical_music_nn', 'size': '1038'}