SimpleTranscriptor / src /streamlit_app.py
Foxosy's picture
Update src/streamlit_app.py
790f9dd verified
import streamlit as st
import whisper
import tempfile
import os
MODEL_OPTIONS = ["tiny", "base", "small", "medium", "large"]
LANGUAGE_OPTIONS = ["en", "ta", "hi", "ml", "te"]
@st.cache_resource
def load_model(model_name):
return whisper.load_model(model_name)
st.title("🎧 Whisper Audio Transcriber")
st.markdown("Transcribe Tamil, English or other audio using OpenAI's Whisper model.")
language = st.selectbox("πŸ—£οΈ Select Language", LANGUAGE_OPTIONS, index=1)
model_name = st.selectbox("🧠 Select Whisper Model", MODEL_OPTIONS, index=2)
uploaded_file = st.file_uploader("🎡 Upload your audio file", type=["mp3", "wav", "m4a"])
if uploaded_file:
model = load_model(model_name)
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp:
tmp.write(uploaded_file.read())
tmp_path = tmp.name
st.info(f"Transcribing with `{model_name}` model and language `{language}`...")
try:
result = model.transcribe(tmp_path, language=language)
st.success("βœ… Done!")
st.markdown("#### πŸ“ Transcription Output:")
st.write(result["text"])
except Exception as e:
st.error(f"❌ Error: {e}")
finally:
os.remove(tmp_path)