File size: 1,023 Bytes
d083627
6774799
d083627
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from subtitle_editor import subtitle_editor
from utils import go_to_step, handle_unexpected_exception

def render_step3():
    if not st.session_state.edit_requested:
        go_to_step(4)
        st.rerun()

    st.header("Edit Subtitles")
    st.markdown("Make your changes in the editor below. Clicking 'Save' applies them, while 'Cancel' discards them.")

    editor_result = subtitle_editor(
        initial_document=st.session_state.processed_doc,
        key=f"editor_{st.session_state.session_id}"
    )

    if editor_result is not None:
        try:
            if editor_result.get("action") == "save":
                st.session_state.processed_doc = editor_result.get("document")
                st.toast("✅ Subtitles saved!")
            elif editor_result.get("action") == "cancel":
                st.toast("Editing cancelled. Changes ignored.")
            
            go_to_step(4)
            st.rerun()
        except Exception as e:
            handle_unexpected_exception(e)