ASR_gradio / app.py
Kr08's picture
Update app.py
3e7e003 verified
raw
history blame
1.17 kB
import spaces
import gradio as gr
from audio_processing import process_audio
@spaces.GPU
def gradio_process_audio(audio):
try:
if audio is None:
return "No file uploaded", "", ""
# Extract the sample rate and audio data from the Gradio input
sample_rate, audio_data = audio
# Call the existing process_audio function
detected_lang, transcription, translation = process_audio((sample_rate, audio_data))
return detected_lang, transcription, translation
except Exception as 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()