Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -159,24 +159,31 @@ with right:
|
|
| 159 |
st.markdown('''<h3><i class="fa fa-pencil"></i> Form 2</h3>''', unsafe_allow_html=True)
|
| 160 |
|
| 161 |
# Box 3: Form 2
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
if st.button("Transcribe"):
|
| 165 |
-
if
|
| 166 |
-
st.
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
file_to_transcribe = microphone_input
|
| 170 |
-
elif uploaded_file:
|
| 171 |
-
file_to_transcribe = uploaded_file
|
| 172 |
-
else:
|
| 173 |
-
st.error("ERROR: You have to either use the microphone or upload an audio file")
|
| 174 |
-
file_to_transcribe = None
|
| 175 |
-
|
| 176 |
-
if file_to_transcribe:
|
| 177 |
with st.spinner("Transcribing..."):
|
| 178 |
-
transcription = transcribe(
|
| 179 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
# End of Box 3 and third Carousel Item
|
| 182 |
st.markdown('''<h3><i class="fa fa-pencil"></i> Form 3</h3>''', unsafe_allow_html=True)
|
|
|
|
| 159 |
st.markdown('''<h3><i class="fa fa-pencil"></i> Form 2</h3>''', unsafe_allow_html=True)
|
| 160 |
|
| 161 |
# Box 3: Form 2
|
| 162 |
+
# Audio recording using mic_recorder
|
| 163 |
+
audio = mic_recorder(
|
| 164 |
+
start_prompt="Start recording",
|
| 165 |
+
stop_prompt="Stop recording",
|
| 166 |
+
just_once=False,
|
| 167 |
+
use_container_width=False,
|
| 168 |
+
callback=None,
|
| 169 |
+
key="mic_recorder"
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
uploaded_file = st.file_uploader("Or upload an audio file", type=["mp3", "wav", "flac", "aac"])
|
| 173 |
if st.button("Transcribe"):
|
| 174 |
+
if audio:
|
| 175 |
+
st.success("Recording detected. Transcribing your recording...")
|
| 176 |
+
with open("temp_recording.wav", "wb") as f:
|
| 177 |
+
f.write(audio)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
with st.spinner("Transcribing..."):
|
| 179 |
+
transcription = transcribe("temp_recording.wav")
|
| 180 |
+
st.text_area("Transcription", transcription, height=200)
|
| 181 |
+
elif uploaded_file is not None:
|
| 182 |
+
with st.spinner("Transcribing..."):
|
| 183 |
+
transcription = transcribe(uploaded_file)
|
| 184 |
+
st.text_area("Transcription", transcription, height=200)
|
| 185 |
+
else:
|
| 186 |
+
st.error("Please record audio or upload a file to transcribe.")
|
| 187 |
|
| 188 |
# End of Box 3 and third Carousel Item
|
| 189 |
st.markdown('''<h3><i class="fa fa-pencil"></i> Form 3</h3>''', unsafe_allow_html=True)
|