Spaces:
Sleeping
Sleeping
update recorder ui
Browse files
app.py
CHANGED
@@ -3,8 +3,7 @@ import sys
|
|
3 |
import datetime
|
4 |
import streamlit as st
|
5 |
from asr import load_model, inference
|
6 |
-
from
|
7 |
-
|
8 |
|
9 |
@st.cache_resource
|
10 |
def load_asr_model():
|
@@ -50,10 +49,13 @@ def main():
|
|
50 |
|
51 |
# Record Audio tab
|
52 |
with tab1:
|
53 |
-
|
54 |
-
if
|
55 |
-
|
56 |
-
fname =
|
|
|
|
|
|
|
57 |
|
58 |
# Upload Audio tab
|
59 |
with tab2:
|
@@ -63,14 +65,7 @@ def main():
|
|
63 |
fname = save_audio_file(audio_file.read(), file_extension)
|
64 |
|
65 |
# Transcribe button action
|
66 |
-
if st.button("
|
67 |
-
# Find the newest audio file
|
68 |
-
#audio_file_path = max(
|
69 |
-
# [f for f in os.listdir(".") if f.startswith("audio")],
|
70 |
-
# key=os.path.getctime,
|
71 |
-
#)
|
72 |
-
|
73 |
-
|
74 |
# Transcribe the audio file
|
75 |
transcript_text = transcribe_audio(fname)
|
76 |
|
|
|
3 |
import datetime
|
4 |
import streamlit as st
|
5 |
from asr import load_model, inference
|
6 |
+
from audiorecorder import audiorecorder
|
|
|
7 |
|
8 |
@st.cache_resource
|
9 |
def load_asr_model():
|
|
|
49 |
|
50 |
# Record Audio tab
|
51 |
with tab1:
|
52 |
+
audio = audiorecorder("Click to start recording", "Click to stop recording")
|
53 |
+
if len(audio) > 0:
|
54 |
+
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
55 |
+
fname = f"audio_{timestamp}.wav"
|
56 |
+
audio.export(fname, format="wav")
|
57 |
+
# st.audio(audio_bytes, format="audio/wav")
|
58 |
+
# fname = save_audio_file(audio_bytes, "wav")
|
59 |
|
60 |
# Upload Audio tab
|
61 |
with tab2:
|
|
|
65 |
fname = save_audio_file(audio_file.read(), file_extension)
|
66 |
|
67 |
# Transcribe button action
|
68 |
+
if st.button("Click to transcribe uploaded audio."):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
# Transcribe the audio file
|
70 |
transcript_text = transcribe_audio(fname)
|
71 |
|