Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,12 +30,22 @@ def summarize(video_url: str):
|
|
| 30 |
if not video_id:
|
| 31 |
return "Invalid YouTube URL. Please provide a standard watch link or shorts URL."
|
| 32 |
|
|
|
|
|
|
|
| 33 |
try:
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
except Exception as e:
|
| 37 |
return f"Could not retrieve transcript: {str(e)}\n\nPlease ensure the video has closed captions/subtitles available."
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
try:
|
| 40 |
completion = client.chat.completions.create(
|
| 41 |
model="llama-3.3-70b-versatile",
|
|
@@ -71,7 +81,7 @@ demo = gr.Interface(
|
|
| 71 |
),
|
| 72 |
outputs=gr.Markdown(label="BriefTube Synthesis & Intelligence"),
|
| 73 |
title="BriefTube AI — Video Intelligence Platform",
|
| 74 |
-
description="Asynchronous
|
| 75 |
examples=[
|
| 76 |
["https://www.youtube.com/watch?v=aircAruvnKk"]
|
| 77 |
]
|
|
|
|
| 30 |
if not video_id:
|
| 31 |
return "Invalid YouTube URL. Please provide a standard watch link or shorts URL."
|
| 32 |
|
| 33 |
+
# Robust transcript extraction using modern instance API
|
| 34 |
+
transcript_text = ""
|
| 35 |
try:
|
| 36 |
+
ytt_api = YouTubeTranscriptApi()
|
| 37 |
+
fetched = ytt_api.fetch(video_id)
|
| 38 |
+
if hasattr(fetched, 'to_raw_data'):
|
| 39 |
+
raw_entries = fetched.to_raw_data()
|
| 40 |
+
else:
|
| 41 |
+
raw_entries = fetched
|
| 42 |
+
transcript_text = " ".join([item['text'] if isinstance(item, dict) else item.text for item in raw_entries])
|
| 43 |
except Exception as e:
|
| 44 |
return f"Could not retrieve transcript: {str(e)}\n\nPlease ensure the video has closed captions/subtitles available."
|
| 45 |
|
| 46 |
+
if not transcript_text.strip():
|
| 47 |
+
return "No text could be extracted from this video's subtitles."
|
| 48 |
+
|
| 49 |
try:
|
| 50 |
completion = client.chat.completions.create(
|
| 51 |
model="llama-3.3-70b-versatile",
|
|
|
|
| 81 |
),
|
| 82 |
outputs=gr.Markdown(label="BriefTube Synthesis & Intelligence"),
|
| 83 |
title="BriefTube AI — Video Intelligence Platform",
|
| 84 |
+
description="Asynchronous video summarization pipeline powered by Meta Llama 3.3 70B via Groq LPUs.",
|
| 85 |
examples=[
|
| 86 |
["https://www.youtube.com/watch?v=aircAruvnKk"]
|
| 87 |
]
|