Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. def create_spec(filename,input):
  2. plt.interactive(False)
  3. clip, sample_rate = librosa.load(input+filename + '.m4a', sr=None)
  4. fig = plt.figure(figsize=[0.72,0.72])
  5. ax = fig.add_subplot(111)
  6. ax.axes.get_xaxis().set_visible(False)
  7. ax.axes.get_yaxis().set_visible(False)
  8. ax.set_frame_on(False)
  9. S = librosa.feature.melspectrogram(y=clip, sr=sample_rate)
  10. librosa.display.specshow(librosa.power_to_db(S, ref=np.max))
  11. plt.savefig(input+filename+ '.png', dpi=400, bbox_inches='tight',pad_inches=0)
  12. plt.close()
  13. fig.clf()
  14. plt.close(fig)
  15. plt.close('all')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement