import gradio as gr import os import spaces import string import random def random_word(length): letters = string.ascii_lowercase return "".join(random.choice(letters) for _ in range(length)) @spaces.GPU def convert(input_file): # Convert the file to markdown with pandoc output_file = f"{random_word(16)}.md" os.system(f"pandoc {input_file} -t markdown -o {output_file}") # Read the file and delete with open(output_file, "r") as f: markdown = f.read() os.remove(output_file) return markdown gr.Interface( convert, inputs=gr.File(label="Upload File", type="filepath"), outputs=gr.Text(label="Markdown"), ).launch()