src
audio_to_spectrogram
convert_matplotlib.py
Go to the documentation of this file.
1
try
:
2
# for python2.x
3
from
StringIO
import
StringIO
as
BufIO
4
except
ModuleNotFoundError:
5
# for python3.x
6
from
io
import
BytesIO
as
BufIO
7
8
import
numpy
as
np
9
import
PIL
10
import
PIL.Image
11
12
13
def
convert_matplotlib_to_img
(fig):
14
buf = BufIO()
15
fig.savefig(buf, format=
"png"
)
16
buf.seek(0)
17
img = np.array(
18
PIL.Image.open(buf), dtype=np.uint8)
19
img = img[..., :3]
20
return
img
audio_to_spectrogram.convert_matplotlib.convert_matplotlib_to_img
def convert_matplotlib_to_img(fig)
Definition:
convert_matplotlib.py:13
audio_to_spectrogram
Author(s):
autogenerated on Fri May 16 2025 03:10:45