MinuteBotSpaces / MinuteBotNA.py
jonnatakusuma's picture
sophisticated
11d063e
raw
history blame contribute delete
No virus
990 Bytes
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)