forked from EnkrateiaLucca/openai_whisper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamlit_whisper.py
49 lines (29 loc) · 1 KB
/
streamlit_whisper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Install dependencies
# Linux
# sudo apt update && sudo apt install ffmpeg
# MacOS
# brew install ffmpeg
# Windows
# chco install ffmpeg
# Installing pytorch
# conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
# Installing Whisper
# pip install git+https://github.com/openai/whisper.git -q
# pip install streamlit
import streamlit as st
import whisper
st.title("Whisper App")
# upload audio file with streamlit
audio_file = st.file_uploader("Upload Audio", type=["wav", "mp3", "m4a"])
model = whisper.load_model("base")
st.text("Whisper Model Loaded")
if st.sidebar.button("Transcribe Audio"):
if audio_file is not None:
st.sidebar.success("Transcribing Audio")
transcription = model.transcribe(audio_file.name)
st.sidebar.success("Transcription Complete")
st.markdown(transcription["text"])
else:
st.sidebar.error("Please upload an audio file")
st.sidebar.header("Play Original Audio File")
st.sidebar.audio(audio_file)