import altair as alt import numpy as np import pandas as pd import streamlit as st """ # Welcome to Streamlit! Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:. If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community forums](https://discuss.streamlit.io). In the meantime, below is an example of what you can do with just a few lines of code: """ num_points = st.slider("Number of points in spiral", 1, 10000, 1100) num_turns = st.slider("Number of turns in spiral", 1, 300, 31) indices = np.linspace(0, 1, num_points) theta = 2 * np.pi * num_turns * indices radius = indices x = radius * np.cos(theta) y = radius * np.sin(theta) df = pd.DataFrame({ "x": x, "y": y, "idx": indices, "rand": np.random.randn(num_points), }) st.altair_chart(alt.Chart(df, height=700, width=700) .mark_point(filled=True) .encode( x=alt.X("x", axis=None), y=alt.Y("y", axis=None), color=alt.Color("idx", legend=None, scale=alt.Scale()), size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])), )) # import streamlit as st # import whisper # import tempfile # import os # import torchaudio # # Title and description # st.title("๐ŸŽง Whisper Audio Transcriber") # st.markdown("Upload a `.wav` or `.mp3` file to get transcribed text with timestamps using Whisper.") # # Load Whisper model # @st.cache_resource # def load_model(): # return whisper.load_model("base") # model = load_model() # st.success("โœ… Whisper model loaded!") # # File uploader # audio_file = st.file_uploader("Upload audio file", type=["wav", "mp3"]) # if audio_file is not None: # # Save uploaded file temporarily # with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file: # tmp_file.write(audio_file.read()) # temp_path = tmp_file.name # # Convert MP3 to WAV if needed # if audio_file.name.endswith(".mp3"): # waveform, sample_rate = torchaudio.load(temp_path) # wav_path = temp_path.replace(".wav", "_converted.wav") # torchaudio.save(wav_path, waveform, sample_rate) # os.remove(temp_path) # temp_path = wav_path # # Transcription # st.info("๐Ÿ“ Transcribing...") # result = model.transcribe(temp_path) # # Display segments # st.subheader("๐Ÿ•’ Segments with Timestamps") # for segment in result["segments"]: # st.markdown(f"**[{segment['start']:.2f}s - {segment['end']:.2f}s]**: {segment['text']}") # # Full transcription # st.subheader("๐Ÿงพ Full Transcript") # st.text_area("Transcribed Text", result["text"], height=250) # # Clean up # os.remove(temp_path)