File size: 933 Bytes
6bc5b8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()