eternalBlissard
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -12,25 +12,7 @@ import os
|
|
12 |
import re
|
13 |
from math import floor
|
14 |
import subprocess
|
15 |
-
|
16 |
-
try:
|
17 |
-
ffmpeg_location = subprocess.check_output(["ffmpeg"], shell=True, text=True)
|
18 |
-
print(f"Location of ffmpeg.exe: {ffmpeg_location.strip()}")
|
19 |
-
except subprocess.CalledProcessError:
|
20 |
-
print("ffmpeg.exe not found in the system PATH.")
|
21 |
-
|
22 |
-
# Command to find the location of ffmpeg.exe
|
23 |
-
try:
|
24 |
-
ffmpeg_location = subprocess.check_output(["which", "ffmpeg"], shell=True, text=True)
|
25 |
-
print(f"Location of ffmpeg.exe: {ffmpeg_location.strip()}")
|
26 |
-
except subprocess.CalledProcessError:
|
27 |
-
print("ffmpeg.exe not found in the system PATH.")
|
28 |
-
|
29 |
-
try:
|
30 |
-
ffmpeg_location = subprocess.check_output(["whereis","ffmpeg"], shell=True, text=True)
|
31 |
-
print(f"Location of ffmpeg.exe: {ffmpeg_location.strip()}")
|
32 |
-
except subprocess.CalledProcessError:
|
33 |
-
print("ffmpeg.exe not found in the system PATH.")
|
34 |
|
35 |
ACCESS_TOKEN = os.getenv("HF_TOKEN")
|
36 |
|
@@ -39,6 +21,9 @@ client = OpenAI(
|
|
39 |
api_key=ACCESS_TOKEN,
|
40 |
)
|
41 |
|
|
|
|
|
|
|
42 |
# val = None
|
43 |
@spaces.GPU(duration=1)
|
44 |
def random_name_generator():
|
@@ -51,19 +36,6 @@ def random_name_generator():
|
|
51 |
# print(random_name_generator())
|
52 |
|
53 |
|
54 |
-
def outputProducer(inputVideo):
|
55 |
-
print(inputVideo)
|
56 |
-
input_file = ffmpeg.input(inputVideo)
|
57 |
-
name_random = random_name_generator()
|
58 |
-
input_file.output('audio'+name_random+'.mp3', acodec='mp3').run()
|
59 |
-
command2 = ["whisper",'./audio'+name_random+'.mp3']
|
60 |
-
try:
|
61 |
-
retVal = subprocess.check_output(command2)
|
62 |
-
except:
|
63 |
-
retVal = subprocess.check_output("ls")
|
64 |
-
subprocess.run(['rm', 'audio'+name_random+'.mp3'], check=True)
|
65 |
-
return retVal
|
66 |
-
|
67 |
def subtitle_it(subtitle_str):
|
68 |
# Regular expression to extract time and text
|
69 |
pattern = re.compile(
|
@@ -105,7 +77,12 @@ def respond(
|
|
105 |
):
|
106 |
# global val
|
107 |
# if ((val is None) or reprocess):
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
109 |
val = subtitle_it(subtitles)
|
110 |
# print(val)
|
111 |
# reprocess-=1
|
|
|
12 |
import re
|
13 |
from math import floor
|
14 |
import subprocess
|
15 |
+
from gradio_client import Client, handle_file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
ACCESS_TOKEN = os.getenv("HF_TOKEN")
|
18 |
|
|
|
21 |
api_key=ACCESS_TOKEN,
|
22 |
)
|
23 |
|
24 |
+
clientsub = Client("eternalBlissard/Simplify-Video-Zero")
|
25 |
+
|
26 |
+
|
27 |
# val = None
|
28 |
@spaces.GPU(duration=1)
|
29 |
def random_name_generator():
|
|
|
36 |
# print(random_name_generator())
|
37 |
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
def subtitle_it(subtitle_str):
|
40 |
# Regular expression to extract time and text
|
41 |
pattern = re.compile(
|
|
|
77 |
):
|
78 |
# global val
|
79 |
# if ((val is None) or reprocess):
|
80 |
+
|
81 |
+
subtitles = clientsub.predict(
|
82 |
+
inputVideo={"video":handle_file(system_message)},
|
83 |
+
api_name="/predict"
|
84 |
+
)
|
85 |
+
|
86 |
val = subtitle_it(subtitles)
|
87 |
# print(val)
|
88 |
# reprocess-=1
|