Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -72,14 +72,22 @@ def plot_spectrogram(wav_file, output_image):
|
|
72 |
|
73 |
# Create a plot for the spectrogram
|
74 |
plt.figure(figsize=(10, 4))
|
75 |
-
plt.specgram(audio_data, Fs=sample_rate, NFFT=1024, noverlap=512, cmap='
|
76 |
-
plt.title('Spectrogram')
|
77 |
-
plt.xlabel('Time [s]')
|
78 |
-
plt.ylabel('Frequency [Hz]')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
# Save the plot as an image file
|
81 |
-
plt.
|
82 |
-
plt.savefig(output_image)
|
83 |
plt.close()
|
84 |
|
85 |
def infer(video_in):
|
|
|
72 |
|
73 |
# Create a plot for the spectrogram
|
74 |
plt.figure(figsize=(10, 4))
|
75 |
+
plt.specgram(audio_data, Fs=sample_rate, NFFT=1024, noverlap=512, cmap='gray', aspect='auto')
|
76 |
+
plt.title('Spectrogram', fontsize=14)
|
77 |
+
plt.xlabel('Time [s]', fontsize=12)
|
78 |
+
plt.ylabel('Frequency [Hz]', fontsize=12)
|
79 |
+
|
80 |
+
# Add a colorbar and adjust its label
|
81 |
+
cbar = plt.colorbar()
|
82 |
+
cbar.set_label('Intensity', fontsize=12)
|
83 |
+
|
84 |
+
# Remove gridlines and ticks for a cleaner look
|
85 |
+
plt.grid(False)
|
86 |
+
plt.xticks([])
|
87 |
+
plt.yticks([])
|
88 |
|
89 |
# Save the plot as an image file
|
90 |
+
plt.savefig(output_image, bbox_inches='tight', pad_inches=0, dpi=300)
|
|
|
91 |
plt.close()
|
92 |
|
93 |
def infer(video_in):
|