├── audo_sample.m4a ├── README.md └── streamlit_whisper.py /audo_sample.m4a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnkrateiaLucca/openai_whisper/HEAD/audo_sample.m4a -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Whisper App with Streamlit 2 | 3 | Python script for my article and Youtube video on building 4 | a streamlit app to use whisper for speech-to-text transcription 5 | 6 | - *Youtube Video*: https://www.youtube.com/watch?v=cNLXzXyuzUs&t=375s 7 | - *Article*: https://medium.com/p/9cd1ab6a24b0 8 | -------------------------------------------------------------------------------- /streamlit_whisper.py: -------------------------------------------------------------------------------- 1 | # Install dependencies 2 | 3 | # Linux 4 | # sudo apt update && sudo apt install ffmpeg 5 | 6 | # MacOS 7 | # brew install ffmpeg 8 | 9 | # Windows 10 | # chco install ffmpeg 11 | 12 | # Installing pytorch 13 | # conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia 14 | 15 | # Installing Whisper 16 | # pip install git+https://github.com/openai/whisper.git -q 17 | 18 | # pip install streamlit 19 | import streamlit as st 20 | import whisper 21 | 22 | st.title("Whisper App") 23 | 24 | # upload audio file with streamlit 25 | audio_file = st.file_uploader("Upload Audio", type=["wav", "mp3", "m4a"]) 26 | 27 | model = whisper.load_model("base") 28 | st.text("Whisper Model Loaded") 29 | 30 | 31 | if st.sidebar.button("Transcribe Audio"): 32 | if audio_file is not None: 33 | st.sidebar.success("Transcribing Audio") 34 | transcription = model.transcribe(audio_file.name) 35 | st.sidebar.success("Transcription Complete") 36 | st.markdown(transcription["text"]) 37 | else: 38 | st.sidebar.error("Please upload an audio file") 39 | 40 | 41 | st.sidebar.header("Play Original Audio File") 42 | st.sidebar.audio(audio_file) 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | --------------------------------------------------------------------------------