Spaces:
Running
Running
delete global VIDEO_ID
Browse files
app.py
CHANGED
@@ -72,7 +72,6 @@ else:
|
|
72 |
|
73 |
TRANSCRIPTS = []
|
74 |
CURRENT_INDEX = 0
|
75 |
-
VIDEO_ID = ""
|
76 |
|
77 |
OPEN_AI_CLIENT = OpenAI(api_key=OPEN_AI_KEY)
|
78 |
GROQ_CLIENT = Groq(api_key=GROQ_API_KEY)
|
@@ -531,8 +530,6 @@ def process_youtube_link(password, link):
|
|
531 |
# 使用 YouTube API 获取逐字稿
|
532 |
# 假设您已经获取了 YouTube 视频的逐字稿并存储在变量 `transcript` 中
|
533 |
video_id = extract_youtube_id(link)
|
534 |
-
global VIDEO_ID
|
535 |
-
VIDEO_ID = video_id
|
536 |
|
537 |
try:
|
538 |
transcript = process_transcript_and_screenshots_on_gcs(video_id)
|
@@ -627,12 +624,12 @@ def create_formatted_simple_transcript(transcript):
|
|
627 |
formatted_simple_transcript.append(line)
|
628 |
return formatted_simple_transcript
|
629 |
|
630 |
-
def create_formatted_transcript(transcript):
|
631 |
formatted_transcript = []
|
632 |
for entry in transcript:
|
633 |
start_time = format_seconds_to_time(entry['start'])
|
634 |
end_time = format_seconds_to_time(entry['start'] + entry['duration'])
|
635 |
-
embed_url = get_embedded_youtube_link(
|
636 |
img_file_id = entry['img_file_id']
|
637 |
screenshot_path = img_file_id
|
638 |
line = {
|
@@ -1454,7 +1451,7 @@ def create_LLM_content(video_id, df_string, kind):
|
|
1454 |
else:
|
1455 |
transcript = df_string
|
1456 |
formatted_simple_transcript = create_formatted_simple_transcript(transcript)
|
1457 |
-
formatted_transcript = create_formatted_transcript(transcript)
|
1458 |
content = generate_key_moments(formatted_simple_transcript, formatted_transcript)
|
1459 |
update_LLM_content(video_id, content, kind)
|
1460 |
content = json.dumps(content, ensure_ascii=False, indent=2)
|
|
|
72 |
|
73 |
TRANSCRIPTS = []
|
74 |
CURRENT_INDEX = 0
|
|
|
75 |
|
76 |
OPEN_AI_CLIENT = OpenAI(api_key=OPEN_AI_KEY)
|
77 |
GROQ_CLIENT = Groq(api_key=GROQ_API_KEY)
|
|
|
530 |
# 使用 YouTube API 获取逐字稿
|
531 |
# 假设您已经获取了 YouTube 视频的逐字稿并存储在变量 `transcript` 中
|
532 |
video_id = extract_youtube_id(link)
|
|
|
|
|
533 |
|
534 |
try:
|
535 |
transcript = process_transcript_and_screenshots_on_gcs(video_id)
|
|
|
624 |
formatted_simple_transcript.append(line)
|
625 |
return formatted_simple_transcript
|
626 |
|
627 |
+
def create_formatted_transcript(video_id, transcript):
|
628 |
formatted_transcript = []
|
629 |
for entry in transcript:
|
630 |
start_time = format_seconds_to_time(entry['start'])
|
631 |
end_time = format_seconds_to_time(entry['start'] + entry['duration'])
|
632 |
+
embed_url = get_embedded_youtube_link(video_id, entry['start'])
|
633 |
img_file_id = entry['img_file_id']
|
634 |
screenshot_path = img_file_id
|
635 |
line = {
|
|
|
1451 |
else:
|
1452 |
transcript = df_string
|
1453 |
formatted_simple_transcript = create_formatted_simple_transcript(transcript)
|
1454 |
+
formatted_transcript = create_formatted_transcript(video_id, transcript)
|
1455 |
content = generate_key_moments(formatted_simple_transcript, formatted_transcript)
|
1456 |
update_LLM_content(video_id, content, kind)
|
1457 |
content = json.dumps(content, ensure_ascii=False, indent=2)
|