Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import subprocess
|
3 |
+
import os
|
4 |
+
|
5 |
+
def videoxsub(vid):
|
6 |
+
getAudio(vid)
|
7 |
+
getSubs()
|
8 |
+
return [vid, "audio.vtt"]
|
9 |
+
|
10 |
+
def getAudio(vid):
|
11 |
+
if os.path.exists("audio.mp3"):
|
12 |
+
os.remove("audio.mp3")
|
13 |
+
commands_list = [ "ffmpeg", "-i", vid, "audio.mp3" ]
|
14 |
+
subprocess.run(commands_list)
|
15 |
+
|
16 |
+
def getSubs():
|
17 |
+
command_list = [ "whisper", "audio.mp3", "-f", "vtt", "--fp16", "False"]
|
18 |
+
subprocess.run(command_list)
|
19 |
+
|
20 |
+
demo = gr.Interface(fn=videoxsub, inputs="video", outputs="video")
|
21 |
+
|
22 |
+
demo.launch()
|