Spaces:
Sleeping
Sleeping
File size: 1,212 Bytes
dc26c45 |
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 |
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.")
|