Spaces:
Sleeping
Sleeping
add rich debug msg
Browse files- src/streamlit_app.py +27 -5
src/streamlit_app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import streamlit as st
|
| 3 |
from asr import transcribe_file
|
| 4 |
from summarization import summarize_transcript
|
|
@@ -211,17 +210,33 @@ with tab3:
|
|
| 211 |
st.components.v1.html(f"""
|
| 212 |
<script>
|
| 213 |
window.addEventListener('message', (event) => {{
|
|
|
|
| 214 |
if (event.data.type === 'currentTimeUpdate') {{
|
| 215 |
const time = event.data.time;
|
| 216 |
-
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
|
| 219 |
window.HTMLInputElement.prototype,
|
| 220 |
"value"
|
| 221 |
).set;
|
| 222 |
-
nativeInputValueSetter.call(
|
| 223 |
const event = new Event('input', {{ bubbles: true }});
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
| 225 |
}}
|
| 226 |
}}
|
| 227 |
}});
|
|
@@ -229,13 +244,18 @@ with tab3:
|
|
| 229 |
""", height=0)
|
| 230 |
|
| 231 |
# Update session state time if changed
|
|
|
|
| 232 |
if time_input and time_input != "":
|
| 233 |
try:
|
| 234 |
new_time = float(time_input)
|
|
|
|
| 235 |
if new_time != st.session_state.current_time:
|
| 236 |
st.session_state.current_time = new_time
|
| 237 |
debug_log(f"Current playback time updated: {new_time:.2f} seconds", "STATE")
|
|
|
|
|
|
|
| 238 |
except Exception as e:
|
|
|
|
| 239 |
debug_log(f"Invalid time received: {time_input} - {e}", "WARN")
|
| 240 |
# Create dummy component to receive time updates
|
| 241 |
current_time = st.session_state.current_time
|
|
@@ -252,6 +272,7 @@ with tab3:
|
|
| 252 |
try:
|
| 253 |
current_time = float(current_time)
|
| 254 |
except:
|
|
|
|
| 255 |
current_time = 0.0
|
| 256 |
debug_log("Invalid current_time, defaulting to 0.0", "WARN")
|
| 257 |
|
|
@@ -273,6 +294,7 @@ with tab3:
|
|
| 273 |
is_current = start_f <= current_time < end_f
|
| 274 |
if is_current:
|
| 275 |
current_highlighted = idx
|
|
|
|
| 276 |
except Exception as e:
|
| 277 |
debug_log(f"Utterance time conversion error: {e}", "ERROR")
|
| 278 |
is_current = False
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from asr import transcribe_file
|
| 3 |
from summarization import summarize_transcript
|
|
|
|
| 210 |
st.components.v1.html(f"""
|
| 211 |
<script>
|
| 212 |
window.addEventListener('message', (event) => {{
|
| 213 |
+
console.log('[JS] Message received:', event.data);
|
| 214 |
if (event.data.type === 'currentTimeUpdate') {{
|
| 215 |
const time = event.data.time;
|
| 216 |
+
console.log('[JS] currentTimeUpdate received:', time);
|
| 217 |
+
|
| 218 |
+
// Try to find the input by key (may fail due to iframe isolation)
|
| 219 |
+
const inputs = parent.document.querySelectorAll("input");
|
| 220 |
+
let targetInput = null;
|
| 221 |
+
for (let input of inputs) {{
|
| 222 |
+
if (input.getAttribute("key") === "{time_input_key}") {{
|
| 223 |
+
targetInput = input;
|
| 224 |
+
break;
|
| 225 |
+
}}
|
| 226 |
+
}}
|
| 227 |
+
|
| 228 |
+
if (targetInput) {{
|
| 229 |
+
console.log('[JS] Found input, updating value to:', time);
|
| 230 |
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
|
| 231 |
window.HTMLInputElement.prototype,
|
| 232 |
"value"
|
| 233 |
).set;
|
| 234 |
+
nativeInputValueSetter.call(targetInput, time);
|
| 235 |
const event = new Event('input', {{ bubbles: true }});
|
| 236 |
+
targetInput.dispatchEvent(event);
|
| 237 |
+
}} else {{
|
| 238 |
+
console.warn('[JS] Could not find input with key: {time_input_key}');
|
| 239 |
+
console.log('[JS] Available inputs:', inputs.length);
|
| 240 |
}}
|
| 241 |
}}
|
| 242 |
}});
|
|
|
|
| 244 |
""", height=0)
|
| 245 |
|
| 246 |
# Update session state time if changed
|
| 247 |
+
debug_log(f"time_input value: '{time_input}'", "STATE")
|
| 248 |
if time_input and time_input != "":
|
| 249 |
try:
|
| 250 |
new_time = float(time_input)
|
| 251 |
+
debug_log(f"Parsed time: {new_time}", "STATE")
|
| 252 |
if new_time != st.session_state.current_time:
|
| 253 |
st.session_state.current_time = new_time
|
| 254 |
debug_log(f"Current playback time updated: {new_time:.2f} seconds", "STATE")
|
| 255 |
+
else:
|
| 256 |
+
debug_log(f"Time unchanged: {new_time:.2f} seconds", "STATE")
|
| 257 |
except Exception as e:
|
| 258 |
+
debug_log(f"Failed to parse time: '{time_input}' - {e}", "WARN")
|
| 259 |
debug_log(f"Invalid time received: {time_input} - {e}", "WARN")
|
| 260 |
# Create dummy component to receive time updates
|
| 261 |
current_time = st.session_state.current_time
|
|
|
|
| 272 |
try:
|
| 273 |
current_time = float(current_time)
|
| 274 |
except:
|
| 275 |
+
debug_log("Failed to convert current_time to float", "WARN")
|
| 276 |
current_time = 0.0
|
| 277 |
debug_log("Invalid current_time, defaulting to 0.0", "WARN")
|
| 278 |
|
|
|
|
| 294 |
is_current = start_f <= current_time < end_f
|
| 295 |
if is_current:
|
| 296 |
current_highlighted = idx
|
| 297 |
+
debug_log(f"Utterance {idx} is current: [{start_f}-{end_f}] '{text[:20]}...'", "STATE")
|
| 298 |
except Exception as e:
|
| 299 |
debug_log(f"Utterance time conversion error: {e}", "ERROR")
|
| 300 |
is_current = False
|