Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import whisper
|
3 |
+
|
4 |
+
# Load Whisper model
|
5 |
+
model = whisper.load_model("base") # You can change to "small", "medium", or "large"
|
6 |
+
|
7 |
+
def transcribe_audio(audio):
|
8 |
+
# Transcribe the uploaded audio file
|
9 |
+
result = model.transcribe(audio)
|
10 |
+
text = result['text']
|
11 |
+
|
12 |
+
# Simple Tagalog detection (checks for common Tagalog words)
|
13 |
+
tagalog_words = ["ang", "si", "ni", "ay", "sa", "ng"]
|
14 |
+
flagged = any(word in text.split() for word in tagalog_words)
|
15 |
+
|
16 |
+
# Return transcript and flag
|
17 |
+
return text, "⚠ Tagalog detected!" if flagged else "No Tagalog detected"
|
18 |
+
|
19 |
+
# Create Gradio interface
|
20 |
+
iface = gr.Interface(
|
21 |
+
fn=transcribe_audio,
|
22 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
23 |
+
outputs=[gr.Textbox(label="Transcript"), gr.Textbox(label="Flag")],
|
24 |
+
title="ClassWatch Audio Transcriber",
|
25 |
+
description="Upload classroom audio to get a transcript and detect if Tagalog is used."
|
26 |
+
)
|
27 |
+
|
28 |
+
iface.launch()
|