Spaces:
Runtime error
Runtime error
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() | |