add code to display spectogram
This commit is contained in:
@@ -38,6 +38,7 @@ llvmlite==0.43.0
|
|||||||
Markdown==3.7
|
Markdown==3.7
|
||||||
markdown-it-py==3.0.0
|
markdown-it-py==3.0.0
|
||||||
MarkupSafe==3.0.2
|
MarkupSafe==3.0.2
|
||||||
|
matplotlib==3.10.0
|
||||||
matplotlib-inline==0.1.7
|
matplotlib-inline==0.1.7
|
||||||
mdurl==0.1.2
|
mdurl==0.1.2
|
||||||
ml-dtypes==0.4.1
|
ml-dtypes==0.4.1
|
||||||
@@ -77,6 +78,9 @@ pure_eval==0.2.3
|
|||||||
pycparser==2.22
|
pycparser==2.22
|
||||||
Pygments==2.18.0
|
Pygments==2.18.0
|
||||||
pyparsing==3.2.0
|
pyparsing==3.2.0
|
||||||
|
PyQt6==6.8.0
|
||||||
|
PyQt6-Qt6==6.8.1
|
||||||
|
PyQt6_sip==13.9.1
|
||||||
pytest==8.3.4
|
pytest==8.3.4
|
||||||
python-dateutil==2.9.0.post0
|
python-dateutil==2.9.0.post0
|
||||||
PyYAML==6.0.2
|
PyYAML==6.0.2
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import librosa.display
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def display_spectrogram(spec_array: np.ndarray, plot_data: dict):
|
||||||
|
"""
|
||||||
|
Displays a spectrogram array using Matplotlib.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
spec_array (np.ndarray): Spectrogram array (in decibels).
|
||||||
|
plot_data (dict): Metadata for plotting (e.g., sr, x_axis, y_axis).
|
||||||
|
"""
|
||||||
|
plt.figure(figsize=(10, 4))
|
||||||
|
librosa.display.specshow(spec_array, sr=plot_data['sr'], x_axis=plot_data['x_axis'], y_axis=plot_data['y_axis'])
|
||||||
|
plt.colorbar(format='%+2.0f dB')
|
||||||
|
plt.title(f"Spectrogram ({plot_data['y_axis'].upper()} axis)")
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.show()
|
||||||
Reference in New Issue
Block a user