File size: 1,169 Bytes
83418c6
 
175c5b3
c1b97fa
 
83418c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa6ba21
83418c6
 
 
175c5b3
 
 
83418c6
 
 
c1b97fa
83418c6
c1b97fa
83418c6
 
ccf9cca
 
 
aa6ba21
 
 
 
 
c1b97fa
aa6ba21
 
 
175c5b3
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import gradio as gr
import shutil
from main_code import main_loop



DURATION = 10
WAVE_OUTPUT_FILE = "my_audio.wav"

def list_file_sizes():
    path = "."
 
    # Get list of all files only in the given directory
    fun = lambda x : os.path.isfile(os.path.join(path,x))
    files_list = filter(fun, os.listdir(path))
    
    # Create a list of files in directory along with the size
    size_of_file = [
        (f,os.stat(os.path.join(path, f)).st_size)
        for f in files_list
    ]
    # Iterate over list of files along with size
    # and print them one by one.
    for f,s in size_of_file:
        print("{} : {}MB".format(f, round(s/(1024*1024),3)))



def main(audio):

    print(audio)

    shutil.copy(audio, "./my_audio.wav")

    list_file_sizes()

    song = main_loop()

    return audio


import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

demo = gr.Blocks()
mf_transcribe = gr.Interface(
            fn=main,
            inputs=gr.inputs.Audio(source="microphone", type="filepath"),
            outputs="text",
            layout="horizontal",
            theme="huggingface",
        )
mf_transcribe.launch()