ASR_gradio / app.py
Kr08's picture
Update app.py
a77426c verified
raw
history blame
1.2 kB
import gradio as gr
from audio_processing import process_audio
import spaces
@spaces.GPU
def gradio_process_audio(audio):
try:
if audio is None:
return "No file uploaded", "", ""
# The Gradio Audio input with type="numpy" provides a tuple of (sample_rate, audio_data)
# This is exactly what process_audio expects, so we can pass it directly
detected_lang, transcription, translation = process_audio(audio)
return detected_lang, transcription, translation
except Exception as e:
print(f"Error in gradio_process_audio: {str(e)}")
return str(e), "", ""
iface = gr.Interface(
fn=gradio_process_audio,
inputs=gr.Audio(type="numpy"),
outputs=[
gr.Textbox(label="Detected Language"),
gr.Textbox(label="Transcription", lines=5),
gr.Textbox(label="Translation", lines=5)
],
title="Audio Transcription and Translation",
description="Upload an audio file to detect its language, transcribe, and translate it.",
allow_flagging="never",
css=".output-textbox { font-family: 'Noto Sans Devanagari', sans-serif; font-size: 18px; }"
)
if __name__ == "__main__":
iface.launch()