Kr08 commited on
Commit
c569b48
·
verified ·
1 Parent(s): e30002c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -9
app.py CHANGED
@@ -1,12 +1,34 @@
1
- import torch
2
- from model_utils import load_models
3
- from audio_processing import iface
4
 
5
- # Clear GPU cache and load models at startup
6
- torch.cuda.empty_cache()
7
- load_models()
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- if __name__ == "__main__":
10
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
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()