Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from pytube import YouTube
|
|
4 |
from fastapi import FastAPI, Response, Request
|
5 |
import yt_dlp
|
6 |
import uvicorn
|
|
|
7 |
|
8 |
CUSTOM_PATH = "/gradio"
|
9 |
|
@@ -38,6 +39,8 @@ def get_subtitle(url, lang='en'):
|
|
38 |
video_id = info_dict.get("id", None)
|
39 |
if video_id is None:
|
40 |
return None
|
|
|
|
|
41 |
subtitle_file = f"{video_id}.{lang}.vtt"
|
42 |
with open(subtitle_file, 'r') as f:
|
43 |
subtitle_content = f.read()
|
@@ -75,14 +78,16 @@ def get_audio(url):
|
|
75 |
return yt.streams.filter(only_audio=True)[0].download(filename="tmp.mp4")
|
76 |
|
77 |
def get_transcript(url, model_size, lang, format):
|
|
|
|
|
|
|
78 |
subtitle = get_subtitle(url, lang)
|
79 |
print(subtitle)
|
80 |
return subtitle
|
81 |
|
82 |
model = whisper.load_model(model_size)
|
83 |
|
84 |
-
|
85 |
-
lang = None
|
86 |
|
87 |
result = model.transcribe(download_audio(url), fp16=False, language=lang)
|
88 |
|
|
|
4 |
from fastapi import FastAPI, Response, Request
|
5 |
import yt_dlp
|
6 |
import uvicorn
|
7 |
+
import os
|
8 |
|
9 |
CUSTOM_PATH = "/gradio"
|
10 |
|
|
|
39 |
video_id = info_dict.get("id", None)
|
40 |
if video_id is None:
|
41 |
return None
|
42 |
+
os.listdir()
|
43 |
+
print(info_dict)
|
44 |
subtitle_file = f"{video_id}.{lang}.vtt"
|
45 |
with open(subtitle_file, 'r') as f:
|
46 |
subtitle_content = f.read()
|
|
|
78 |
return yt.streams.filter(only_audio=True)[0].download(filename="tmp.mp4")
|
79 |
|
80 |
def get_transcript(url, model_size, lang, format):
|
81 |
+
if lang == "None":
|
82 |
+
lang = None
|
83 |
+
|
84 |
subtitle = get_subtitle(url, lang)
|
85 |
print(subtitle)
|
86 |
return subtitle
|
87 |
|
88 |
model = whisper.load_model(model_size)
|
89 |
|
90 |
+
|
|
|
91 |
|
92 |
result = model.transcribe(download_audio(url), fp16=False, language=lang)
|
93 |
|