Spaces:
Sleeping
Sleeping
eternalBlissard
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -4,16 +4,30 @@ import os
|
|
4 |
import ffmpeg
|
5 |
# import pymedia.audio.acodec as acodec
|
6 |
# import pymedia.muxer as muxer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def outputProducer(inputVideo):
|
9 |
print(inputVideo)
|
10 |
input_file = ffmpeg.input(inputVideo)
|
11 |
-
|
12 |
-
|
|
|
13 |
try:
|
14 |
retVal = subprocess.check_output(command2)
|
15 |
except:
|
16 |
retVal = subprocess.check_output("ls")
|
|
|
17 |
return retVal
|
18 |
demo = gr.Interface(fn=outputProducer,
|
19 |
inputs = [gr.Video()],
|
|
|
4 |
import ffmpeg
|
5 |
# import pymedia.audio.acodec as acodec
|
6 |
# import pymedia.muxer as muxer
|
7 |
+
import random
|
8 |
+
import string
|
9 |
+
|
10 |
+
def random_name_generator():
|
11 |
+
length = random.randint(10, 15) # Random length between 10 and 15
|
12 |
+
characters = string.ascii_letters + string.digits # All alphanumeric characters
|
13 |
+
random_name = ''.join(random.choice(characters) for _ in range(length))
|
14 |
+
return random_name
|
15 |
+
|
16 |
+
# Example usage:
|
17 |
+
# print(random_name_generator())
|
18 |
+
|
19 |
|
20 |
def outputProducer(inputVideo):
|
21 |
print(inputVideo)
|
22 |
input_file = ffmpeg.input(inputVideo)
|
23 |
+
name_random = random_name_generator()
|
24 |
+
input_file.output('audio'+name_random+'.mp3', acodec='mp3').run()
|
25 |
+
command2 = ["whisper",'./audio'+name_random+'.mp3']
|
26 |
try:
|
27 |
retVal = subprocess.check_output(command2)
|
28 |
except:
|
29 |
retVal = subprocess.check_output("ls")
|
30 |
+
subprocess.run(['rm', 'audio'+name_random+'.mp3'], check=True)
|
31 |
return retVal
|
32 |
demo = gr.Interface(fn=outputProducer,
|
33 |
inputs = [gr.Video()],
|