Merge f0b67bd15955983622a2aa45b43165cb704c57c7 into 7ef19867780cf703841ebafb565a4e47d1ea86ff

This commit is contained in:
Myungchul Keum 2025-02-04 01:02:55 +00:00 committed by GitHub
commit 6c2244c11d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -225,7 +225,6 @@ def plot_spectrogram_to_numpy(spectrogram):
mpl_logger = logging.getLogger("matplotlib") mpl_logger = logging.getLogger("matplotlib")
mpl_logger.setLevel(logging.WARNING) mpl_logger.setLevel(logging.WARNING)
import matplotlib.pylab as plt import matplotlib.pylab as plt
import numpy as np
fig, ax = plt.subplots(figsize=(10, 2)) fig, ax = plt.subplots(figsize=(10, 2))
im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation="none") im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation="none")
@ -235,8 +234,7 @@ def plot_spectrogram_to_numpy(spectrogram):
plt.tight_layout() plt.tight_layout()
fig.canvas.draw() fig.canvas.draw()
data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep="") data = np.asarray(fig.canvas.buffer_rgba())
data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
plt.close() plt.close()
return data return data
@ -251,7 +249,6 @@ def plot_alignment_to_numpy(alignment, info=None):
mpl_logger = logging.getLogger("matplotlib") mpl_logger = logging.getLogger("matplotlib")
mpl_logger.setLevel(logging.WARNING) mpl_logger.setLevel(logging.WARNING)
import matplotlib.pylab as plt import matplotlib.pylab as plt
import numpy as np
fig, ax = plt.subplots(figsize=(6, 4)) fig, ax = plt.subplots(figsize=(6, 4))
im = ax.imshow( im = ax.imshow(
@ -266,8 +263,7 @@ def plot_alignment_to_numpy(alignment, info=None):
plt.tight_layout() plt.tight_layout()
fig.canvas.draw() fig.canvas.draw()
data = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep="") data = np.asarray(fig.canvas.buffer_rgba())
data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
plt.close() plt.close()
return data return data