22 lines
711 B
Python
22 lines
711 B
Python
#import the pyplot and wavfile modules
|
|
import matplotlib.pyplot as plt
|
|
from scipy.io import wavfile
|
|
# Read the wav file (mono)
|
|
file = "Car721035-2020-Pass0-Z2-PaRecAR628069_20200725_005937_000.wav"
|
|
file_path = f"/var/www/chiro-canto/public/storage/records/{file}"
|
|
print(file)
|
|
samplingFrequency, signalData = wavfile.read(file_path)
|
|
# Plot the signal read from wav file
|
|
# plt.subplot(211)
|
|
# plt.title('Spectrogram of a wav file with piano music')
|
|
# plt.plot(signalData)
|
|
# plt.xlabel('Sample')
|
|
# plt.ylabel('Amplitude')
|
|
# plt.subplot(212)
|
|
plt.specgram(signalData,Fs=samplingFrequency)
|
|
# plt.xlabel('Time')
|
|
# plt.ylabel('Frequency')
|
|
plt.savefig(f'/var/www/chiro-canto/public/storage/records/{file}')
|
|
plt.show()
|
|
|
|
|