File size: 1,312 Bytes
72b90bc
 
 
 
1991b96
 
52443ac
 
cc30204
52443ac
 
 
 
 
 
 
 
 
 
cc30204
72b90bc
cc631b9
72b90bc
52443ac
 
 
09de3a2
 
 
 
52443ac
72b90bc
7b8a487
72b90bc
 
 
7b8a487
72b90bc
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import gradio as gr
import subprocess
import os
import ffmpeg
# import pymedia.audio.acodec as acodec
# import pymedia.muxer as muxer
import random
import string
import spaces

def random_name_generator():
    length = random.randint(10, 15)  # Random length between 10 and 15
    characters = string.ascii_letters + string.digits  # All alphanumeric characters
    random_name = ''.join(random.choice(characters) for _ in range(length))
    return random_name

# Example usage:
# print(random_name_generator())

@spaces.GPU(duration = 100)
def outputProducer(inputVideo):
    print(inputVideo)
    input_file = ffmpeg.input(inputVideo)
    name_random = random_name_generator()
    input_file.output('audio'+name_random+'.mp3', acodec='mp3').run()
    command2 = ["whisper",'./audio'+name_random+'.mp3']
    try:
        retVal = subprocess.check_output(command2)
    except:
        retVal = subprocess.check_output("ls")
    subprocess.run(['rm', 'audio'+name_random+'.mp3'], check=True) 
    return retVal
exampleList = [["examples/" + example] for example in os.listdir("examples")]
demo = gr.Interface(fn=outputProducer,
                    inputs = [gr.Video()],
                    outputs= [gr.Textbox()],
                    examples=exampleList, 
                    title = 'Simplify')
demo.launch()