turbo_whisper / app.py
ahmadmac's picture
Upload app.py
dc26c45 verified
import streamlit as st
import whisper
# Load the Whisper model
@st.cache_resource
def load_model():
return whisper.load_model("turbo")
model = load_model()
# Streamlit app
st.title("Audio Transcription App")
st.header("Using Whisper for Audio Transcription")
# File uploader
uploaded_file = st.file_uploader("Upload an audio file (e.g., MP3, WAV, etc.)", type=["mp3", "wav", "m4a"])
if uploaded_file is not None:
st.audio(uploaded_file, format="audio/mp3", start_time=0)
# Transcribe button
if st.button("Transcribe Audio"):
with st.spinner("Transcribing..."):
# Save the uploaded file to a temporary location
with open("temp_audio_file.mp3", "wb") as temp_file:
temp_file.write(uploaded_file.read())
# Perform transcription
result = model.transcribe("temp_audio_file.mp3")
transcription_text = result["text"]
st.success("Transcription Completed!")
st.subheader("Transcription:")
st.text_area("Here is the transcription:", transcription_text, height=300)
else:
st.info("Please upload an audio file to start the transcription.")