Spaces:
Sleeping
Sleeping
| 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"]) | |