Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,34 @@
|
|
1 |
-
import
|
2 |
-
from
|
3 |
-
from audio_processing import iface
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from audio_processing import process_audio
|
|
|
3 |
|
4 |
+
def gradio_process_audio(audio):
|
5 |
+
try:
|
6 |
+
if audio is None:
|
7 |
+
return "No file uploaded", "", ""
|
8 |
+
|
9 |
+
# Extract the sample rate and audio data from the Gradio input
|
10 |
+
sample_rate, audio_data = audio
|
11 |
+
|
12 |
+
# Call the existing process_audio function
|
13 |
+
detected_lang, transcription, translation = process_audio((sample_rate, audio_data))
|
14 |
+
|
15 |
+
return detected_lang, transcription, translation
|
16 |
+
except Exception as e:
|
17 |
+
return str(e), "", ""
|
18 |
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn=gradio_process_audio,
|
21 |
+
inputs=gr.Audio(type="numpy"),
|
22 |
+
outputs=[
|
23 |
+
gr.Textbox(label="Detected Language"),
|
24 |
+
gr.Textbox(label="Transcription", lines=5),
|
25 |
+
gr.Textbox(label="Translation", lines=5)
|
26 |
+
],
|
27 |
+
title="Audio Transcription and Translation",
|
28 |
+
description="Upload an audio file to detect its language, transcribe, and translate it.",
|
29 |
+
allow_flagging="never",
|
30 |
+
css=".output-textbox { font-family: 'Noto Sans Devanagari', sans-serif; font-size: 18px; }"
|
31 |
+
)
|
32 |
|
33 |
+
if __name__ == "__main__":
|
34 |
+
iface.launch()
|