Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
-
from audio_processing import process_audio
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
# The Gradio Audio input with type="numpy" provides a tuple of (sample_rate, audio_data)
|
12 |
-
# This is exactly what process_audio expects, so we can pass it directly
|
13 |
-
detected_lang, transcription, translation = process_audio(audio)
|
14 |
-
|
15 |
-
return detected_lang, transcription, translation
|
16 |
-
except Exception as e:
|
17 |
-
print(f"Error in gradio_process_audio: {str(e)}")
|
18 |
-
return str(e), "", ""
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
iface = gr.Interface(
|
22 |
-
fn=
|
23 |
-
inputs=gr.Audio(type="
|
24 |
-
outputs=
|
25 |
-
|
26 |
-
gr.Textbox(label="Transcription", lines=5),
|
27 |
-
gr.Textbox(label="Translation", lines=5)
|
28 |
-
],
|
29 |
-
title="Audio Transcription and Translation",
|
30 |
-
description="Upload an audio file to detect its language, transcribe, and translate it.",
|
31 |
-
allow_flagging="never",
|
32 |
-
css=".output-textbox { font-family: 'Noto Sans Devanagari', sans-serif; font-size: 18px; }"
|
33 |
)
|
34 |
|
35 |
-
|
36 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from audio_processing import process_audio, print_results
|
3 |
+
def transcribe_audio(audio_file):
|
4 |
+
language_segments, final_segments = process_audio(audio_file)
|
5 |
+
|
6 |
+
output = "Detected language changes:\n\n"
|
7 |
+
for segment in language_segments:
|
8 |
+
output += f"Language: {segment['language']}\n"
|
9 |
+
output += f"Time: {segment['start']:.2f}s - {segment['end']:.2f}s\n\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
output += "Transcription with language detection and speaker diarization:\n\n"
|
12 |
+
for segment in final_segments:
|
13 |
+
output += f"[{segment['start']:.2f}s - {segment['end']:.2f}s] ({segment['language']}) Speaker {segment['speaker']}: {segment['text']}\n"
|
14 |
+
# output += f"[{segment['start']:.2f}s - {segment['end']:.2f}s] ({segment['language']}): {segment['text']}\n"
|
15 |
+
return output
|
16 |
|
17 |
iface = gr.Interface(
|
18 |
+
fn=transcribe_audio,
|
19 |
+
inputs=gr.Audio(type="filepath"),
|
20 |
+
outputs="text",
|
21 |
+
title="WhisperX Audio Transcription"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
)
|
23 |
|
24 |
+
iface.launch()
|
|