ahmadmac commited on
Commit
dc26c45
·
verified ·
1 Parent(s): 4870f3a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import whisper
3
+
4
+ # Load the Whisper model
5
+ @st.cache_resource
6
+ def load_model():
7
+ return whisper.load_model("turbo")
8
+
9
+ model = load_model()
10
+
11
+ # Streamlit app
12
+ st.title("Audio Transcription App")
13
+ st.header("Using Whisper for Audio Transcription")
14
+
15
+ # File uploader
16
+ uploaded_file = st.file_uploader("Upload an audio file (e.g., MP3, WAV, etc.)", type=["mp3", "wav", "m4a"])
17
+
18
+ if uploaded_file is not None:
19
+ st.audio(uploaded_file, format="audio/mp3", start_time=0)
20
+
21
+ # Transcribe button
22
+ if st.button("Transcribe Audio"):
23
+ with st.spinner("Transcribing..."):
24
+ # Save the uploaded file to a temporary location
25
+ with open("temp_audio_file.mp3", "wb") as temp_file:
26
+ temp_file.write(uploaded_file.read())
27
+
28
+ # Perform transcription
29
+ result = model.transcribe("temp_audio_file.mp3")
30
+ transcription_text = result["text"]
31
+
32
+ st.success("Transcription Completed!")
33
+ st.subheader("Transcription:")
34
+ st.text_area("Here is the transcription:", transcription_text, height=300)
35
+ else:
36
+ st.info("Please upload an audio file to start the transcription.")