Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,12 @@ def get_transcript(video_url, lang_sel, model_sel, api_key_input):
|
|
| 9 |
|
| 10 |
try:
|
| 11 |
video_id = video_url.split("v=")[1].split("&")[0]
|
|
|
|
|
|
|
| 12 |
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
| 13 |
raw_text = " ".join([entry["text"] for entry in transcript])
|
| 14 |
-
|
|
|
|
| 15 |
if lang_sel != "English":
|
| 16 |
prompt = f"Translate this text to {lang_sel} language: {raw_text}"
|
| 17 |
response = client.models.generate_content(
|
|
@@ -19,9 +22,12 @@ def get_transcript(video_url, lang_sel, model_sel, api_key_input):
|
|
| 19 |
contents=[prompt]
|
| 20 |
)
|
| 21 |
return response.text
|
|
|
|
| 22 |
return raw_text
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
def process_transcript(video_url, word_count, model_sel, lang_sel, api_key_input):
|
|
|
|
| 9 |
|
| 10 |
try:
|
| 11 |
video_id = video_url.split("v=")[1].split("&")[0]
|
| 12 |
+
print(f"Extracted Video ID: {video_id}") # Debugging
|
| 13 |
+
|
| 14 |
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
| 15 |
raw_text = " ".join([entry["text"] for entry in transcript])
|
| 16 |
+
print(f"Retrieved Transcript: {raw_text[:500]}") # Print first 500 characters
|
| 17 |
+
|
| 18 |
if lang_sel != "English":
|
| 19 |
prompt = f"Translate this text to {lang_sel} language: {raw_text}"
|
| 20 |
response = client.models.generate_content(
|
|
|
|
| 22 |
contents=[prompt]
|
| 23 |
)
|
| 24 |
return response.text
|
| 25 |
+
|
| 26 |
return raw_text
|
| 27 |
+
|
| 28 |
+
except (NoTranscriptFound, VideoUnavailable, TranscriptsDisabled) as e:
|
| 29 |
+
print(f"Transcript Retrieval Error: {e}") # Debugging
|
| 30 |
+
return f"⚠️ Error: {e}"
|
| 31 |
|
| 32 |
|
| 33 |
def process_transcript(video_url, word_count, model_sel, lang_sel, api_key_input):
|