| import gradio as gr | |
| from transformers import pipeline | |
| # ดึงโมเดลรุ่น Tiny ที่คุณ Duplicate มาไว้ในบัญชีตัวเอง | |
| pipe = pipeline("automatic-speech-recognition", model="Pinatpong/whisper-tiny") | |
| def transcribe(audio): | |
| if audio is None: | |
| return "" | |
| # ถอดความเสียงเป็นข้อความ | |
| result = pipe(audio) | |
| return result["text"] | |
| # สร้างหน้าต่างรับเสียงแบบง่ายๆ | |
| iface = gr.Interface( | |
| fn=transcribe, | |
| inputs=gr.Audio(type="filepath"), | |
| outputs="text", | |
| title="Megatron Voice Assistant (Whisper Tiny)" | |
| ) | |
| iface.launch() |