Spaces:
Build error
Build error
File size: 1,201 Bytes
c569b48 a77426c 65fb837 c569b48 a77426c c569b48 a77426c c569b48 f36e52e a77426c c569b48 f36e52e c569b48 |
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 29 30 31 32 33 34 35 36 |
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() |