19 lines
447 B
Python
19 lines
447 B
Python
|
import matplotlib.pyplot as plt
|
||
|
import librosa
|
||
|
import numpy as np
|
||
|
import os
|
||
|
import sys
|
||
|
|
||
|
args = sys.argv
|
||
|
|
||
|
file_path = args[1]
|
||
|
file_name = os.path.basename(file_path)
|
||
|
|
||
|
(sig, rate) = librosa.load(file_path, sr=None, mono=True, dtype=np.float32)
|
||
|
plt.specgram(sig, Fs=rate, NFFT=2048)
|
||
|
|
||
|
plt.subplots_adjust(left=0,right=1,bottom=0,top=1)
|
||
|
plt.axis('tight')
|
||
|
plt.axis('off')
|
||
|
|
||
|
plt.savefig(f"/var/www/chiro-canto/public/storage/spectrograms/{file_name}.png")
|