eternalBlissard commited on
Commit
e9b6ee1
·
verified ·
1 Parent(s): 5e72581

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -19
app.py CHANGED
@@ -12,7 +12,6 @@ import os
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,10 +20,7 @@ client = OpenAI(
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():
30
  length = random.randint(10, 15) # Random length between 10 and 15
@@ -36,6 +32,19 @@ 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(
@@ -68,23 +77,18 @@ def subtitle_it(subtitle_str):
68
 
69
  def respond(
70
  message,
71
- history: list[tuple[str, str]],
72
- reprocess,
73
  system_message,
 
74
  max_tokens,
75
  temperature,
76
  top_p,
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
89
  messages = [{"role": "system", "content": "Answer by using the transcript"+val}]
90
 
@@ -134,5 +138,3 @@ demo = gr.ChatInterface(
134
  )
135
  if __name__ == "__main__":
136
  demo.launch()
137
-
138
-
 
12
  import re
13
  from math import floor
14
  import subprocess
 
15
 
16
  ACCESS_TOKEN = os.getenv("HF_TOKEN")
17
 
 
20
  api_key=ACCESS_TOKEN,
21
  )
22
 
23
+ val = None
 
 
 
24
  @spaces.GPU(duration=1)
25
  def random_name_generator():
26
  length = random.randint(10, 15) # Random length between 10 and 15
 
32
  # print(random_name_generator())
33
 
34
 
35
+ def outputProducer(inputVideo):
36
+ print(inputVideo)
37
+ input_file = ffmpeg.input(inputVideo)
38
+ name_random = random_name_generator()
39
+ input_file.output('audio'+name_random+'.mp3', acodec='mp3').run()
40
+ command2 = ["whisper",'./audio'+name_random+'.mp3']
41
+ try:
42
+ retVal = subprocess.check_output(command2)
43
+ except:
44
+ retVal = subprocess.check_output("ls")
45
+ subprocess.run(['rm', 'audio'+name_random+'.mp3'], check=True)
46
+ return retVal
47
+
48
  def subtitle_it(subtitle_str):
49
  # Regular expression to extract time and text
50
  pattern = re.compile(
 
77
 
78
  def respond(
79
  message,
80
+ history: list[tuple([str, str])],
 
81
  system_message,
82
+ reprocess,
83
  max_tokens,
84
  temperature,
85
  top_p,
86
  ):
87
+ global val
88
+ if ((val is None) or reprocess):
89
+ subtitles = outputProducer(system_message)
90
+ val = subtitle_it(subtitles)
91
+ print(val)
 
 
 
 
 
92
  # reprocess-=1
93
  messages = [{"role": "system", "content": "Answer by using the transcript"+val}]
94
 
 
138
  )
139
  if __name__ == "__main__":
140
  demo.launch()