Spaces:
Running
Running
Fabio Grasso
commited on
Commit
·
2c9d596
1
Parent(s):
214114c
feat: improve karaoke with yt video secs change, fix session page missing err
Browse files- app/header.py +3 -0
- app/pages/Karaoke.py +10 -5
app/header.py
CHANGED
@@ -25,9 +25,12 @@ def header(logo_and_title=True):
|
|
25 |
"url",
|
26 |
"random_song",
|
27 |
"last_dir",
|
|
|
28 |
]:
|
29 |
st.session_state[key] = None
|
30 |
st.session_state.video_options = []
|
|
|
|
|
31 |
st.session_state.page = "Karaoke"
|
32 |
switch_page(st.session_state.page)
|
33 |
|
|
|
25 |
"url",
|
26 |
"random_song",
|
27 |
"last_dir",
|
28 |
+
"player_restart",
|
29 |
]:
|
30 |
st.session_state[key] = None
|
31 |
st.session_state.video_options = []
|
32 |
+
st.session_state.tot_delay = 0
|
33 |
+
if "page" not in st.session_state:
|
34 |
st.session_state.page = "Karaoke"
|
35 |
switch_page(st.session_state.page)
|
36 |
|
app/pages/Karaoke.py
CHANGED
@@ -27,7 +27,7 @@ in_path = Path("/tmp")
|
|
27 |
sess = st.session_state
|
28 |
|
29 |
|
30 |
-
def show_karaoke(pathname
|
31 |
cols = st.columns([1, 1, 3, 1])
|
32 |
with cols[1]:
|
33 |
sess.delay = st.slider(
|
@@ -62,10 +62,15 @@ def show_karaoke(pathname, initial_player):
|
|
62 |
unsafe_allow_html=True,
|
63 |
)
|
64 |
with st.columns([1, 4, 1])[1]:
|
65 |
-
if events.name == "
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
67 |
st_player(
|
68 |
-
sess.url + f"&t={sess.
|
69 |
**{
|
70 |
"progress_interval": 1000,
|
71 |
"playing": True,
|
@@ -167,7 +172,7 @@ def body():
|
|
167 |
sess.executed = True
|
168 |
|
169 |
if sess.executed:
|
170 |
-
show_karaoke(out_path / "vocal_remover" / sess.last_dir / "no_vocals.mp3"
|
171 |
|
172 |
|
173 |
if __name__ == "__main__":
|
|
|
27 |
sess = st.session_state
|
28 |
|
29 |
|
30 |
+
def show_karaoke(pathname):
|
31 |
cols = st.columns([1, 1, 3, 1])
|
32 |
with cols[1]:
|
33 |
sess.delay = st.slider(
|
|
|
62 |
unsafe_allow_html=True,
|
63 |
)
|
64 |
with st.columns([1, 4, 1])[1]:
|
65 |
+
if events.name == "onPlay":
|
66 |
+
st.session_state.player_restart = True
|
67 |
+
|
68 |
+
elif events.name == "onProgress":
|
69 |
+
if st.session_state.player_restart:
|
70 |
+
sess.tot_delay = sess.delay + events.data["playedSeconds"]
|
71 |
+
st.session_state.player_restart = False
|
72 |
st_player(
|
73 |
+
sess.url + f"&t={sess.tot_delay}s",
|
74 |
**{
|
75 |
"progress_interval": 1000,
|
76 |
"playing": True,
|
|
|
172 |
sess.executed = True
|
173 |
|
174 |
if sess.executed:
|
175 |
+
show_karaoke(out_path / "vocal_remover" / sess.last_dir / "no_vocals.mp3")
|
176 |
|
177 |
|
178 |
if __name__ == "__main__":
|