Spaces:
Sleeping
Sleeping
Skriller0208
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,32 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import time
|
3 |
+
from whisper_processor import process_audio
|
4 |
|
5 |
+
def process_audio_streamlit(audio_file, model_name, lang):
|
6 |
+
start_time = time.time()
|
7 |
+
result = process_audio(audio_file, model_name=model_name, lang=lang)
|
8 |
+
end_time = time.time()
|
9 |
+
elapsed_time = end_time - start_time
|
10 |
+
st.write("Time taken:", elapsed_time, "seconds")
|
11 |
+
return result
|
12 |
+
|
13 |
+
st.title("Audio Transcription")
|
14 |
+
|
15 |
+
# Upload audio file
|
16 |
+
uploaded_file = st.file_uploader("Choose an audio file")
|
17 |
+
|
18 |
+
# Select model and language
|
19 |
+
model_name = st.selectbox("Select model", ["tiny", "base", "small", "medium", "large"])
|
20 |
+
lang = st.selectbox("Select language", ["en", "hi", "fr", "de", "es", "it", "pt", "ru", "zh", "ja", "ko", "ar", "tr"])
|
21 |
+
|
22 |
+
if uploaded_file is not None:
|
23 |
+
# Save the uploaded file to a temporary location
|
24 |
+
with open("temp.wav", "wb") as f:
|
25 |
+
f.write(uploaded_file.read())
|
26 |
+
|
27 |
+
# Process the audio file
|
28 |
+
result = process_audio_streamlit("temp.wav", model_name, lang)
|
29 |
+
|
30 |
+
# Display the transcription result
|
31 |
+
st.write("Transcription:")
|
32 |
+
st.text_area("", value=result, height=300)
|