Spaces:
Sleeping
Sleeping
requirements, app.py
Browse files- Dockerfile +6 -5
- requirements.txt +4 -1
- src/streamlit_app.py +31 -34
Dockerfile
CHANGED
|
@@ -2,6 +2,9 @@ FROM python:3.9-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
build-essential \
|
| 7 |
curl \
|
|
@@ -14,8 +17,6 @@ COPY src/ ./src/
|
|
| 14 |
|
| 15 |
RUN pip3 install -r requirements.txt
|
| 16 |
|
| 17 |
-
EXPOSE
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
RUN mkdir -p /.streamlit && chmod 777 /.streamlit
|
| 6 |
+
RUN mkdir -p /tmp && chmod 777 /tmp
|
| 7 |
+
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
| 10 |
curl \
|
|
|
|
| 17 |
|
| 18 |
RUN pip3 install -r requirements.txt
|
| 19 |
|
| 20 |
+
EXPOSE 7860
|
| 21 |
+
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
|
| 22 |
+
ENTRYPOINT ["streamlit", "run", ..., "--server.port=7860"]
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1,3 +1,6 @@
|
|
| 1 |
altair
|
| 2 |
pandas
|
| 3 |
-
streamlit
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
altair
|
| 2 |
pandas
|
| 3 |
+
streamlit
|
| 4 |
+
openai-whisper
|
| 5 |
+
torch
|
| 6 |
+
torchaudio
|
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,37 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
In the meantime, below is an example of what you can do with just a few lines of code:
|
| 14 |
-
"""
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
theta = 2 * np.pi * num_turns * indices
|
| 21 |
-
radius = indices
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
"idx": indices,
|
| 30 |
-
"rand": np.random.randn(num_points),
|
| 31 |
-
})
|
| 32 |
|
| 33 |
-
st.
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
y=alt.Y("y", axis=None),
|
| 38 |
-
color=alt.Color("idx", legend=None, scale=alt.Scale()),
|
| 39 |
-
size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
|
| 40 |
-
))
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ["STREAMLIT_HOME"] = "/tmp"
|
| 3 |
+
os.environ["MPLCONFIGDIR"] = "/tmp"
|
| 4 |
+
os.environ["STREAMLIT_BROWSER_GATHER_USAGE_STATS"] = "false"
|
| 5 |
+
os.environ["STREAMLIT_WATCHER_TYPE"] = "none"
|
| 6 |
+
|
| 7 |
+
import asyncio
|
| 8 |
+
try:
|
| 9 |
+
asyncio.get_running_loop()
|
| 10 |
+
except RuntimeError:
|
| 11 |
+
loop = asyncio.new_event_loop()
|
| 12 |
+
asyncio.set_event_loop(loop)
|
| 13 |
|
| 14 |
+
import streamlit as st
|
| 15 |
+
import whisper
|
| 16 |
+
import uuid
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
st.title("🧪 Whisper Tiny ASR (No Diarization)")
|
| 19 |
+
st.write("Upload an audio file (wav/mp3/m4a) and get a quick transcription using Whisper Tiny.")
|
| 20 |
|
| 21 |
+
uploaded = st.file_uploader("Choose an audio file", type=["wav", "mp3", "m4a", "flac"])
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
if uploaded:
|
| 24 |
+
audio_id = uuid.uuid4().hex
|
| 25 |
+
audio_path = f"/tmp/audio_{audio_id}.wav"
|
| 26 |
+
with open(audio_path, "wb") as f:
|
| 27 |
+
f.write(uploaded.read())
|
| 28 |
+
st.success(f"✅ File saved to {audio_path}")
|
| 29 |
|
| 30 |
+
if st.button("Transcribe"):
|
| 31 |
+
with st.spinner("Loading Whisper (tiny)..."):
|
| 32 |
+
model = whisper.load_model("tiny").to("cpu")
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
with st.spinner("Transcribing..."):
|
| 35 |
+
result = model.transcribe(audio_path, language="id")
|
| 36 |
+
st.header("📝 Transcription Result")
|
| 37 |
+
st.markdown(result["text"])
|
|
|
|
|
|
|
|
|
|
|
|