Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,11 +11,18 @@ st.set_page_config(page_title="Video-to-Text Summarization", layout="wide")
|
|
11 |
|
12 |
# Header
|
13 |
st.title("π₯ Smart Video-to-Text Summarization App")
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Temporary video storage
|
17 |
if "video_path" not in st.session_state:
|
18 |
st.session_state.video_path = None
|
|
|
|
|
19 |
|
20 |
# Upload Video Section
|
21 |
st.header("Upload Your Video")
|
@@ -50,9 +57,10 @@ if youtube_upload_btn:
|
|
50 |
# Process Video Section
|
51 |
if st.session_state.video_path:
|
52 |
st.header("Process Your Video")
|
|
|
53 |
st.write(f"Processing {st.session_state.video_path}...")
|
54 |
|
55 |
-
process_btn = st.button("
|
56 |
|
57 |
if process_btn:
|
58 |
def extract_audio(video_path):
|
@@ -71,17 +79,18 @@ if st.session_state.video_path:
|
|
71 |
try:
|
72 |
model = whisper.load_model("base")
|
73 |
result = model.transcribe(audio_path)
|
74 |
-
st.
|
|
|
75 |
return result['text']
|
76 |
except Exception as e:
|
77 |
st.error(f"Error in transcription: {str(e)}")
|
78 |
return None
|
79 |
|
80 |
if audio_path:
|
81 |
-
transcription = transcribe_audio(audio_path)
|
82 |
|
83 |
# Summarize and Translate Section
|
84 |
-
if
|
85 |
st.header("Results")
|
86 |
|
87 |
summarize_btn = st.button("π Summarize Text")
|
@@ -99,7 +108,7 @@ if 'transcription' in locals():
|
|
99 |
|
100 |
summary = None
|
101 |
if summarize_btn:
|
102 |
-
summary = summarize_text(transcription)
|
103 |
|
104 |
def translate_text(text, src_lang="en", tgt_lang="es"):
|
105 |
try:
|
|
|
11 |
|
12 |
# Header
|
13 |
st.title("π₯ Smart Video-to-Text Summarization App")
|
14 |
+
st.markdown("""
|
15 |
+
This app helps you:
|
16 |
+
- Convert videos into text and summarize them.
|
17 |
+
- Extract multilingual transcriptions and translations.
|
18 |
+
- Process videos with multiple speakers.
|
19 |
+
""")
|
20 |
|
21 |
# Temporary video storage
|
22 |
if "video_path" not in st.session_state:
|
23 |
st.session_state.video_path = None
|
24 |
+
if "transcription" not in st.session_state:
|
25 |
+
st.session_state.transcription = None
|
26 |
|
27 |
# Upload Video Section
|
28 |
st.header("Upload Your Video")
|
|
|
57 |
# Process Video Section
|
58 |
if st.session_state.video_path:
|
59 |
st.header("Process Your Video")
|
60 |
+
st.video(st.session_state.video_path)
|
61 |
st.write(f"Processing {st.session_state.video_path}...")
|
62 |
|
63 |
+
process_btn = st.button("π Process Video", key="process-video", help="Click to start processing", use_container_width=True)
|
64 |
|
65 |
if process_btn:
|
66 |
def extract_audio(video_path):
|
|
|
79 |
try:
|
80 |
model = whisper.load_model("base")
|
81 |
result = model.transcribe(audio_path)
|
82 |
+
st.session_state.transcription = result['text']
|
83 |
+
st.text_area("Transcription", st.session_state.transcription, height=200)
|
84 |
return result['text']
|
85 |
except Exception as e:
|
86 |
st.error(f"Error in transcription: {str(e)}")
|
87 |
return None
|
88 |
|
89 |
if audio_path:
|
90 |
+
st.session_state.transcription = transcribe_audio(audio_path)
|
91 |
|
92 |
# Summarize and Translate Section
|
93 |
+
if st.session_state.transcription:
|
94 |
st.header("Results")
|
95 |
|
96 |
summarize_btn = st.button("π Summarize Text")
|
|
|
108 |
|
109 |
summary = None
|
110 |
if summarize_btn:
|
111 |
+
summary = summarize_text(st.session_state.transcription)
|
112 |
|
113 |
def translate_text(text, src_lang="en", tgt_lang="es"):
|
114 |
try:
|