Main Page
Namespaces
Namespace List
Namespace Members
All
Functions
Variables
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
p
q
r
s
t
u
w
Functions
_
a
c
f
i
p
r
s
t
u
w
Variables
_
a
b
d
e
f
g
h
i
l
m
n
p
q
s
t
w
Files
File List
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 Sat Feb 22 2025 04:03:22