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