Spaces:
Sleeping
Sleeping
generate_transcription_by_whisper
Browse files
app.py
CHANGED
|
@@ -380,7 +380,7 @@ def get_transcript(video_id):
|
|
| 380 |
continue # 當前語言的字幕沒有找到,繼續嘗試下一個語言
|
| 381 |
return None # 所有嘗試都失敗,返回None
|
| 382 |
|
| 383 |
-
def
|
| 384 |
youtube_url = f'https://www.youtube.com/watch?v={video_id}'
|
| 385 |
codec_name = "mp3"
|
| 386 |
outtmpl = f"{OUTPUT_PATH}/{video_id}.%(ext)s"
|
|
@@ -461,13 +461,13 @@ def process_transcript_and_screenshots_on_gcs(video_id):
|
|
| 461 |
except:
|
| 462 |
# call open ai whisper
|
| 463 |
print("===call open ai whisper===")
|
| 464 |
-
transcript =
|
| 465 |
|
| 466 |
if transcript:
|
| 467 |
print("成功獲取字幕")
|
| 468 |
else:
|
| 469 |
print("沒有找到字幕")
|
| 470 |
-
transcript =
|
| 471 |
|
| 472 |
transcript_text = json.dumps(transcript, ensure_ascii=False, indent=2)
|
| 473 |
upload_file_to_gcs_with_json_string(gcs_client, bucket_name, transcript_blob_name, transcript_text)
|
|
|
|
| 380 |
continue # 當前語言的字幕沒有找到,繼續嘗試下一個語言
|
| 381 |
return None # 所有嘗試都失敗,返回None
|
| 382 |
|
| 383 |
+
def generate_transcription_by_whisper(video_id):
|
| 384 |
youtube_url = f'https://www.youtube.com/watch?v={video_id}'
|
| 385 |
codec_name = "mp3"
|
| 386 |
outtmpl = f"{OUTPUT_PATH}/{video_id}.%(ext)s"
|
|
|
|
| 461 |
except:
|
| 462 |
# call open ai whisper
|
| 463 |
print("===call open ai whisper===")
|
| 464 |
+
transcript = generate_transcription_by_whisper(video_id)
|
| 465 |
|
| 466 |
if transcript:
|
| 467 |
print("成功獲取字幕")
|
| 468 |
else:
|
| 469 |
print("沒有找到字幕")
|
| 470 |
+
transcript = generate_transcription_by_whisper(video_id)
|
| 471 |
|
| 472 |
transcript_text = json.dumps(transcript, ensure_ascii=False, indent=2)
|
| 473 |
upload_file_to_gcs_with_json_string(gcs_client, bucket_name, transcript_blob_name, transcript_text)
|