Spaces:
Sleeping
Sleeping
File size: 789 Bytes
4569044 b3d840a 4569044 |
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 |
import gradio as gr
from typing import Optional
from tool import HFSpeech2TextFromFile
tool = HFSpeech2TextFromFile()
def read_and_process_file(file, token):
"""Reads the uploaded file and processes its content."""
try:
processed_content = tool(filepath=file.name, hf_token=token)
return processed_content
except Exception as e:
return f"Error: {e}"
# Gradio interface
iface = gr.Interface(
fn=read_and_process_file,
inputs=[gr.File(label="Upload a file"), gr.Textbox(label="Enter your huggingface API token here")],
outputs=gr.Textbox(label="File Content"),
title="File Reader",
description="Upload an audio file and retrieve its transcript."
)
# Required for Hugging Face Spaces
if __name__ == "__main__":
iface.launch()
|