Spaces:
Runtime error
Runtime error
David Li commited on
Commit ·
5f40cee
1
Parent(s): 6ecd4f1
fix: low id coder
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from openbb_terminal.forecast.whisper_model import transcribe_and_summarize
|
|
| 9 |
|
| 10 |
def get_video_id(url):
|
| 11 |
|
| 12 |
-
video_id = re.findall(r"v=([
|
| 13 |
old_stdin = sys.stdin
|
| 14 |
# mkdir /home/user/.cache/whisper
|
| 15 |
os.makedirs(f"/home/user/.cache/whisper", exist_ok=True)
|
|
@@ -27,11 +27,18 @@ def get_video_id(url):
|
|
| 27 |
# get latest file with *_summary.txt
|
| 28 |
summary_file = max(glob.glob(f"**/*_summary.txt"), key=os.path.getctime)
|
| 29 |
# file .srt file
|
|
|
|
| 30 |
try:
|
| 31 |
-
subtitle_file = glob.glob(f"{video_id}/*.
|
| 32 |
except Exception as e:
|
| 33 |
# get latest file with .srt or .vtt
|
| 34 |
-
subtitle_file = max(glob.glob(f"**/*.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
return summary_file, subtitle_file
|
| 36 |
|
| 37 |
input_text = gr.inputs.Textbox(label="Enter a YouTube URL")
|
|
|
|
| 9 |
|
| 10 |
def get_video_id(url):
|
| 11 |
|
| 12 |
+
video_id = re.findall(r"v=([\w]{11})", url)[0]
|
| 13 |
old_stdin = sys.stdin
|
| 14 |
# mkdir /home/user/.cache/whisper
|
| 15 |
os.makedirs(f"/home/user/.cache/whisper", exist_ok=True)
|
|
|
|
| 27 |
# get latest file with *_summary.txt
|
| 28 |
summary_file = max(glob.glob(f"**/*_summary.txt"), key=os.path.getctime)
|
| 29 |
# file .srt file
|
| 30 |
+
subtitle_file = None
|
| 31 |
try:
|
| 32 |
+
subtitle_file = glob.glob(f"{video_id}/*.vtt")[0]
|
| 33 |
except Exception as e:
|
| 34 |
# get latest file with .srt or .vtt
|
| 35 |
+
subtitle_file = max(glob.glob(f"**/*.vtt"), key=os.path.getctime)
|
| 36 |
+
|
| 37 |
+
if subtitle_file = None:
|
| 38 |
+
try:
|
| 39 |
+
subtitle_file = glob.glob(f"{video_id}/*.srt")[0]
|
| 40 |
+
except Exception as e:
|
| 41 |
+
subtitle_file = max(glob.glob(f"**/*.srt"), key=os.path.getctime)
|
| 42 |
return summary_file, subtitle_file
|
| 43 |
|
| 44 |
input_text = gr.inputs.Textbox(label="Enter a YouTube URL")
|