Spaces:
Running
Running
fabiogra
commited on
Commit
ยท
faebcc3
1
Parent(s):
4c92361
fix: search_results session state events playedSeconds, log karaoke
Browse files- app/pages/Karaoke.py +4 -1
- app/service/youtube.py +3 -2
app/pages/Karaoke.py
CHANGED
@@ -19,6 +19,7 @@ from helpers import (
|
|
19 |
from service.vocal_remover.runner import separate, load_model
|
20 |
from footer import footer
|
21 |
from header import header
|
|
|
22 |
|
23 |
|
24 |
out_path = Path("/tmp")
|
@@ -64,8 +65,9 @@ def show_karaoke(pathname):
|
|
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
|
@@ -108,6 +110,7 @@ def body():
|
|
108 |
with yt_cols[2]:
|
109 |
if st.button("๐ฒ Random song", use_container_width=True):
|
110 |
sess.last_dir, sess.url = get_random_song()
|
|
|
111 |
sess.random_song = True
|
112 |
sess.video_options = []
|
113 |
sess.executed = False
|
|
|
19 |
from service.vocal_remover.runner import separate, load_model
|
20 |
from footer import footer
|
21 |
from header import header
|
22 |
+
from loguru import logger as log
|
23 |
|
24 |
|
25 |
out_path = Path("/tmp")
|
|
|
65 |
with st.columns([1, 4, 1])[1]:
|
66 |
if events.name == "onPlay":
|
67 |
st.session_state.player_restart = True
|
68 |
+
log.info(f"Play Karaoke - {sess.selected_value}")
|
69 |
|
70 |
+
elif events.name == "onProgress" and events.data["playedSeconds"] > 0:
|
71 |
if st.session_state.player_restart:
|
72 |
sess.tot_delay = sess.delay + events.data["playedSeconds"]
|
73 |
st.session_state.player_restart = False
|
|
|
110 |
with yt_cols[2]:
|
111 |
if st.button("๐ฒ Random song", use_container_width=True):
|
112 |
sess.last_dir, sess.url = get_random_song()
|
113 |
+
sess.selected_value = sess.last_dir
|
114 |
sess.random_song = True
|
115 |
sess.video_options = []
|
116 |
sess.executed = False
|
app/service/youtube.py
CHANGED
@@ -61,10 +61,11 @@ def search_youtube(query: str) -> List:
|
|
61 |
time.sleep(0.5)
|
62 |
search = query_youtube(query + " lyrics")
|
63 |
st.session_state.search_results = search.results
|
64 |
-
|
65 |
-
|
66 |
else:
|
67 |
video_options = []
|
|
|
68 |
return video_options
|
69 |
|
70 |
|
|
|
61 |
time.sleep(0.5)
|
62 |
search = query_youtube(query + " lyrics")
|
63 |
st.session_state.search_results = search.results
|
64 |
+
if st.session_state.search_results is not None:
|
65 |
+
video_options = [video.title for video in st.session_state.search_results]
|
66 |
else:
|
67 |
video_options = []
|
68 |
+
st.session_state.video_options = video_options
|
69 |
return video_options
|
70 |
|
71 |
|