Spaces:
Sleeping
Sleeping
File size: 990 Bytes
11d063e |
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 |
import streamlit as st
import whisper
from tempfile import NamedTemporaryFile
import ffmpeg
st.title("Whisper App")
# upload audio file with streamlit
audio_file = st.file_uploader("Upload Meeting Audio", type=["m4a", "mp3", "wav"])
st.text("Whisper Model Loaded")
def load_whisper_model():
return model
def convert_m4a_to_mp3(input_path, output_path):
audio = AudioSegment.from_file(input_path, format="m4a")
audio.export(output_path, format="mp3")
if st.sidebar.button("Transcribe Audio"):
if audio_file is not None:
with NamedTemporaryFile(suffix="mp3") as temp:
temp.write(audio_file.getvalue())
temp.seek(0)
model = whisper.load_model("base")
temp_mp3_path = temp.name
convert_m4a_to_mp3(audio_file, temp_mp3_path)
result = model.transcribe(temp_mp3_path)
st.write(result["text"])
st.sidebar.header("Play Original Audio File")
st.sidebar.audio(audio_file) |