Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +55 -1
src/streamlit_app.py
CHANGED
|
@@ -37,4 +37,58 @@ st.altair_chart(alt.Chart(df, height=700, width=700)
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 41 |
+
|
| 42 |
+
))
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# import streamlit as st
|
| 46 |
+
# import whisper
|
| 47 |
+
# import tempfile
|
| 48 |
+
# import os
|
| 49 |
+
# import torchaudio
|
| 50 |
+
|
| 51 |
+
# # Title and description
|
| 52 |
+
# st.title("🎧 Whisper Audio Transcriber")
|
| 53 |
+
# st.markdown("Upload a `.wav` or `.mp3` file to get transcribed text with timestamps using Whisper.")
|
| 54 |
+
|
| 55 |
+
# # Load Whisper model
|
| 56 |
+
# @st.cache_resource
|
| 57 |
+
# def load_model():
|
| 58 |
+
# return whisper.load_model("base")
|
| 59 |
+
|
| 60 |
+
# model = load_model()
|
| 61 |
+
# st.success("✅ Whisper model loaded!")
|
| 62 |
+
|
| 63 |
+
# # File uploader
|
| 64 |
+
# audio_file = st.file_uploader("Upload audio file", type=["wav", "mp3"])
|
| 65 |
+
|
| 66 |
+
# if audio_file is not None:
|
| 67 |
+
# # Save uploaded file temporarily
|
| 68 |
+
# with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 69 |
+
# tmp_file.write(audio_file.read())
|
| 70 |
+
# temp_path = tmp_file.name
|
| 71 |
+
|
| 72 |
+
# # Convert MP3 to WAV if needed
|
| 73 |
+
# if audio_file.name.endswith(".mp3"):
|
| 74 |
+
# waveform, sample_rate = torchaudio.load(temp_path)
|
| 75 |
+
# wav_path = temp_path.replace(".wav", "_converted.wav")
|
| 76 |
+
# torchaudio.save(wav_path, waveform, sample_rate)
|
| 77 |
+
# os.remove(temp_path)
|
| 78 |
+
# temp_path = wav_path
|
| 79 |
+
|
| 80 |
+
# # Transcription
|
| 81 |
+
# st.info("📝 Transcribing...")
|
| 82 |
+
# result = model.transcribe(temp_path)
|
| 83 |
+
|
| 84 |
+
# # Display segments
|
| 85 |
+
# st.subheader("🕒 Segments with Timestamps")
|
| 86 |
+
# for segment in result["segments"]:
|
| 87 |
+
# st.markdown(f"**[{segment['start']:.2f}s - {segment['end']:.2f}s]**: {segment['text']}")
|
| 88 |
+
|
| 89 |
+
# # Full transcription
|
| 90 |
+
# st.subheader("🧾 Full Transcript")
|
| 91 |
+
# st.text_area("Transcribed Text", result["text"], height=250)
|
| 92 |
+
|
| 93 |
+
# # Clean up
|
| 94 |
+
# os.remove(temp_path)
|