Spaces:
Sleeping
Sleeping
Commit
·
a2ad006
1
Parent(s):
3188dd2
handling recording error properly!
Browse files
app.py
CHANGED
@@ -334,32 +334,33 @@ def process_file(ser_model,tokenizer,gpt_model,gpt_tokenizer):
|
|
334 |
|
335 |
try:
|
336 |
record_audio(output_wav_file, duration=4)
|
337 |
-
except OSError as e:
|
338 |
-
if "[Errno -9996]" in str(e) and "Invalid input device (no default output device)" in str(e):
|
339 |
-
st.error("Recording not possible as no input device on cloud platforms. Please upload instead.")
|
340 |
-
else:
|
341 |
-
st.error(f"An error occurred while recording: {str(e)}")
|
342 |
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
|
348 |
-
|
349 |
-
|
350 |
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
|
358 |
-
|
359 |
-
|
360 |
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
|
364 |
if st.session_state.stage > 0:
|
365 |
if st.button(button_label,on_click=set_stage, args=(2,)):
|
|
|
334 |
|
335 |
try:
|
336 |
record_audio(output_wav_file, duration=4)
|
|
|
|
|
|
|
|
|
|
|
337 |
|
338 |
+
# # Use a div to encapsulate the audio element and apply the border
|
339 |
+
with st.sidebar.markdown('<div class="audio-container">', unsafe_allow_html=True):
|
340 |
+
# Play recorded sound
|
341 |
+
st.audio(output_wav_file, format="wav")
|
342 |
|
343 |
+
audio_array, sr = librosa.load(preprocessWavFile(output_wav_file), sr=None)
|
344 |
+
st.sidebar.markdown("<p style='font-size: 14px; font-weight: bold;'>Generating transcriptions! Please wait...</p>", unsafe_allow_html=True)
|
345 |
|
346 |
+
transcription = speechtoText(output_wav_file)
|
347 |
+
|
348 |
+
emo = predict(audio_array,ser_model,2,tokenizer,transcription)
|
349 |
+
|
350 |
+
# Display the transcription in a textbox
|
351 |
+
st.sidebar.text_area("Transcription", transcription, height=25)
|
352 |
|
353 |
+
txt = f"You seem to be <b>{(emo2promptMapping[emo]).capitalize()}!</b>\n Click on 'Show Helpful Tips' button to proceed further."
|
354 |
+
st.markdown(f"<div class='mobile-screen' style='font-size: 24px;'>{txt} </div>", unsafe_allow_html=True)
|
355 |
|
356 |
+
# Store the value of emo in the session state
|
357 |
+
st.session_state.emo = emo
|
358 |
+
|
359 |
+
except OSError as e:
|
360 |
+
if "[Errno -9996]" in str(e) and "Invalid input device (no default output device)" in str(e):
|
361 |
+
st.error("Recording not possible as no input device on cloud platforms. Please upload instead.")
|
362 |
+
else:
|
363 |
+
st.error(f"An error occurred while recording: {str(e)}")
|
364 |
|
365 |
if st.session_state.stage > 0:
|
366 |
if st.button(button_label,on_click=set_stage, args=(2,)):
|