Spaces:
Sleeping
Sleeping
File size: 1,218 Bytes
a741559 79ac3f5 a741559 5d6b60c a741559 5d6b60c a741559 5d6b60c a741559 5d6b60c a741559 5d6b60c a741559 5d6b60c a741559 |
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 30 31 32 33 34 35 36 37 38 39 |
import os
os.environ["STREAMLIT_HOME"] = "/tmp"
os.environ["MPLCONFIGDIR"] = "/tmp"
os.environ["STREAMLIT_BROWSER_GATHER_USAGE_STATS"] = "false"
os.environ["STREAMLIT_WATCHER_TYPE"] = "none"
os.environ["XDG_CACHE_HOME"] = "/tmp"
import asyncio
try:
asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
import streamlit as st
import whisper
import uuid
st.title("🧪 Whisper Tiny ASR (No Diarization)")
st.write("Upload an audio file (wav/mp3/m4a) and get a quick transcription using Whisper Tiny.")
uploaded = st.file_uploader("Choose an audio file", type=["wav", "mp3", "m4a", "flac"])
if uploaded:
audio_id = uuid.uuid4().hex
audio_path = f"/tmp/audio_{audio_id}.wav"
with open(audio_path, "wb") as f:
f.write(uploaded.read())
st.success(f"✅ File saved to {audio_path}")
if st.button("Transcribe"):
with st.spinner("Loading Whisper (tiny)..."):
model = whisper.load_model("tiny").to("cpu")
with st.spinner("Transcribing..."):
result = model.transcribe(audio_path, language="id")
st.header("📝 Transcription Result")
st.markdown(result["text"])
|