awacke1 commited on
Commit
576e642
·
1 Parent(s): bce517b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -72,13 +72,18 @@ def transcribe_audio(openai_key, file_path, model):
72
  return None
73
 
74
  def save_and_play_audio(audio_recorder):
75
- audio_bytes = st.sidebar.audio_recorder()
76
- if audio_bytes:
77
- filename = generate_filename("Recording", "wav")
78
- with open(filename, 'wb') as f:
79
- f.write(audio_bytes)
80
- st.audio(audio_bytes, format="audio/wav")
81
- return filename
 
 
 
 
 
82
  return None
83
 
84
  # Updated to call direct from transcription to chat inference.
 
72
  return None
73
 
74
  def save_and_play_audio(audio_recorder):
75
+ col1 = st.sidebar.columns([1]) # adjust the ratio as needed
76
+ with col1:
77
+ try:
78
+ audio_bytes = audio_recorder()
79
+ if audio_bytes:
80
+ filename = generate_filename("Recording", "wav")
81
+ with open(filename, 'wb') as f:
82
+ f.write(audio_bytes)
83
+ st.audio(audio_bytes, format="audio/wav")
84
+ return filename
85
+ except Exception as e:
86
+ st.error(f"Error occurred while processing audio recording")
87
  return None
88
 
89
  # Updated to call direct from transcription to chat inference.