Spaces:
Sleeping
Sleeping
Update app.py
#2
by Axelottle - opened
app.py
CHANGED
|
@@ -31,11 +31,16 @@ def summarize_text(url, percent):
|
|
| 31 |
|
| 32 |
# Get transcript using youtube-transcript-api
|
| 33 |
try:
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
except Exception as e:
|
| 37 |
-
|
| 38 |
-
|
|
|
|
| 39 |
# Clean text
|
| 40 |
|
| 41 |
Cleaned_text = re.sub(r'[^a-zA-Z0-9\._-]', ' ', Text)
|
|
|
|
| 31 |
|
| 32 |
# Get transcript using youtube-transcript-api
|
| 33 |
try:
|
| 34 |
+
ytt_api = YouTubeTranscriptApi()
|
| 35 |
+
transcript = ytt_api.fetch(
|
| 36 |
+
youtube.video_id,
|
| 37 |
+
languages=['en']
|
| 38 |
+
)
|
| 39 |
+
Text = ' '.join(snippet.text for snippet in transcript)
|
| 40 |
except Exception as e:
|
| 41 |
+
print(f"Transcript error: {e}")
|
| 42 |
+
raise gr.Error(f"Could not retrieve the video's transcript: {e}")
|
| 43 |
+
|
| 44 |
# Clean text
|
| 45 |
|
| 46 |
Cleaned_text = re.sub(r'[^a-zA-Z0-9\._-]', ' ', Text)
|