Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import shutil
|
| 3 |
import whisper
|
| 4 |
-
import os
|
| 5 |
model = whisper.load_model("turbo")
|
| 6 |
|
| 7 |
destination_language = "fa" # @param ["en","fa","es","it","fr","du"]
|
|
@@ -18,6 +18,11 @@ def format_time(seconds_float):
|
|
| 18 |
sign = '-' if seconds_float < 0 else ''
|
| 19 |
return f"{sign}{hours:02d}:{minutes:02d}:{seconds:02d},{milliseconds:03d}"
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def subtitle(path):
|
| 22 |
shutil.copyfile(path.name, 'video.mp4')
|
| 23 |
result = model.transcribe('video.mp4')
|
|
@@ -42,6 +47,13 @@ def subtitle2(text):
|
|
| 42 |
gr.set_static_paths(paths=["/home/user/app"])
|
| 43 |
|
| 44 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
with gr.Tab("From Your PC"):
|
| 46 |
gr.Markdown("Upload Video File for Auto Subtitle")
|
| 47 |
with gr.Row():
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import shutil
|
| 3 |
import whisper
|
| 4 |
+
import os, time
|
| 5 |
model = whisper.load_model("turbo")
|
| 6 |
|
| 7 |
destination_language = "fa" # @param ["en","fa","es","it","fr","du"]
|
|
|
|
| 18 |
sign = '-' if seconds_float < 0 else ''
|
| 19 |
return f"{sign}{hours:02d}:{minutes:02d}:{seconds:02d},{milliseconds:03d}"
|
| 20 |
|
| 21 |
+
def ytdown(text):
|
| 22 |
+
os.system(f'yt-dlp -f 18 -o video.mp4 {text} ')
|
| 23 |
+
time.sleep(5)
|
| 24 |
+
return ['video.mp4']
|
| 25 |
+
|
| 26 |
def subtitle(path):
|
| 27 |
shutil.copyfile(path.name, 'video.mp4')
|
| 28 |
result = model.transcribe('video.mp4')
|
|
|
|
| 47 |
gr.set_static_paths(paths=["/home/user/app"])
|
| 48 |
|
| 49 |
with gr.Blocks() as demo:
|
| 50 |
+
with gr.Tab("Download Youtube"):
|
| 51 |
+
gr.Markdown("Enter your link")
|
| 52 |
+
with gr.Row():
|
| 53 |
+
inp = gr.Textbox()
|
| 54 |
+
out = gr.File()
|
| 55 |
+
btn = gr.Button("Download it")
|
| 56 |
+
btn.click(fn=ytdown, inputs=inp, outputs=out)
|
| 57 |
with gr.Tab("From Your PC"):
|
| 58 |
gr.Markdown("Upload Video File for Auto Subtitle")
|
| 59 |
with gr.Row():
|