-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvisualizer.py
More file actions
32 lines (23 loc) · 828 Bytes
/
visualizer.py
File metadata and controls
32 lines (23 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from matplotlib import pyplot as plt
from librosa.display import waveshow
import matplotlib.image as mpimg
import librosa, streamlit as st
from config import VIS_PATH
def plot_wave(y, sr, filepath = VIS_PATH):
fig, ax = plt.subplots()
img = waveshow(y, sr=sr, x_axis='time', ax=ax)
ax.set_facecolor("black")
plt.axis("off")
plt.savefig(filepath, bbox_inches="tight", facecolor="black")
#return plt.gcf()
def displaySoundTrack(saved_song, filepath = VIS_PATH, frame_rate = None):
y, sr = librosa.load(saved_song, sr = frame_rate)
plot_wave(y, sr)
im = mpimg.imread(filepath)
col1, col2, col3 = st.columns([1,6,1])
with col1:
st.write("")
with col2:
st.image(im, width = 500, caption = "Your song made into a soundtrack")
with col3:
st.write("")