Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,6 +29,13 @@ with st.sidebar:
|
|
29 |
index=0)
|
30 |
|
31 |
max_segments = st.slider("Maximum number of segments", 5, 30, 15)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
# Function to create a download link for a file
|
34 |
def get_download_link(file_path, link_text):
|
@@ -325,6 +332,26 @@ if st.button("Process Video"):
|
|
325 |
transcript_progress = st.progress(0, text="Starting transcript extraction...")
|
326 |
transcript = get_video_transcript(video_id, language)
|
327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
if transcript:
|
329 |
transcript_progress.progress(1.0, text=f"Transcript extracted ({len(transcript)} segments)")
|
330 |
|
|
|
29 |
index=0)
|
30 |
|
31 |
max_segments = st.slider("Maximum number of segments", 5, 30, 15)
|
32 |
+
|
33 |
+
# Add manual transcript option
|
34 |
+
manual_transcript = st.checkbox("Enter transcript manually (if extraction fails)")
|
35 |
+
|
36 |
+
if manual_transcript:
|
37 |
+
user_transcript = st.text_area("Paste transcript text (format: timestamps and text)",
|
38 |
+
height=300)
|
39 |
|
40 |
# Function to create a download link for a file
|
41 |
def get_download_link(file_path, link_text):
|
|
|
332 |
transcript_progress = st.progress(0, text="Starting transcript extraction...")
|
333 |
transcript = get_video_transcript(video_id, language)
|
334 |
|
335 |
+
# If automatic extraction fails and manual transcript is provided, use that
|
336 |
+
if not transcript and manual_transcript and 'user_transcript' in locals():
|
337 |
+
if user_transcript.strip():
|
338 |
+
# Parse user-provided transcript into the expected format
|
339 |
+
lines = user_transcript.strip().split('\n')
|
340 |
+
parsed_transcript = []
|
341 |
+
current_time = 0
|
342 |
+
|
343 |
+
for line in lines:
|
344 |
+
# Simple parsing - assumes each line is a new segment
|
345 |
+
parsed_transcript.append({
|
346 |
+
'text': line.strip(),
|
347 |
+
'start': current_time,
|
348 |
+
'duration': 5 # Assume 5 seconds per line
|
349 |
+
})
|
350 |
+
current_time += 5
|
351 |
+
|
352 |
+
transcript = parsed_transcript
|
353 |
+
transcript_progress.progress(1.0, text=f"Using manually entered transcript ({len(transcript)} segments)")
|
354 |
+
|
355 |
if transcript:
|
356 |
transcript_progress.progress(1.0, text=f"Transcript extracted ({len(transcript)} segments)")
|
357 |
|