ClassWatch / app.py
mjalpha's picture
Create app.py
6bc5b8e verified
import gradio as gr
import whisper
# Load Whisper model
model = whisper.load_model("base") # You can change to "small", "medium", or "large"
def transcribe_audio(audio):
# Transcribe the uploaded audio file
result = model.transcribe(audio)
text = result['text']
# Simple Tagalog detection (checks for common Tagalog words)
tagalog_words = ["ang", "si", "ni", "ay", "sa", "ng"]
flagged = any(word in text.split() for word in tagalog_words)
# Return transcript and flag
return text, "⚠ Tagalog detected!" if flagged else "No Tagalog detected"
# Create Gradio interface
iface = gr.Interface(
fn=transcribe_audio,
inputs=gr.Audio(source="upload", type="filepath"),
outputs=[gr.Textbox(label="Transcript"), gr.Textbox(label="Flag")],
title="ClassWatch Audio Transcriber",
description="Upload classroom audio to get a transcript and detect if Tagalog is used."
)
iface.launch()