Spaces:
Running
Running
Vlad Bastina commited on
Commit ·
459e708
1
Parent(s): 5be2676
no record
Browse files
app.py
CHANGED
|
@@ -224,7 +224,7 @@ file_name = None
|
|
| 224 |
# --- ADDED "Use Default Example" option ---
|
| 225 |
input_method = st.radio(
|
| 226 |
"Choose audio input method:",
|
| 227 |
-
("Upload WAV file", "
|
| 228 |
index=0,
|
| 229 |
key="input_method"
|
| 230 |
)
|
|
@@ -236,35 +236,6 @@ if input_method == "Upload WAV file":
|
|
| 236 |
audio_bytes = uploaded_file.getvalue()
|
| 237 |
st.audio(audio_bytes, format='audio/wav')
|
| 238 |
|
| 239 |
-
elif input_method == "Record Audio":
|
| 240 |
-
st.write("Click the microphone to start/stop recording (allow microphone access).")
|
| 241 |
-
# Use streamlit_mic_recorder
|
| 242 |
-
# The key='recorder' helps maintain state across reruns
|
| 243 |
-
audio_info = mic_recorder(
|
| 244 |
-
start_prompt="🔴 Start Recording",
|
| 245 |
-
stop_prompt="⏹️ Stop Recording",
|
| 246 |
-
just_once=False, # Allow multiple recordings without refresh
|
| 247 |
-
use_container_width=True,
|
| 248 |
-
format="wav", # Specify wav format
|
| 249 |
-
key='recorder'
|
| 250 |
-
)
|
| 251 |
-
|
| 252 |
-
if audio_info and audio_info['bytes']:
|
| 253 |
-
st.success("Recording finished!")
|
| 254 |
-
audio_bytes = audio_info['bytes']
|
| 255 |
-
file_name = "recorded_audio.wav"
|
| 256 |
-
st.audio(audio_bytes, format='audio/wav')
|
| 257 |
-
# Optional: ensure WAV format integrity if needed
|
| 258 |
-
# try:
|
| 259 |
-
# audio_segment = AudioSegment.from_file(io.BytesIO(audio_bytes))
|
| 260 |
-
# wav_buffer = io.BytesIO()
|
| 261 |
-
# audio_segment.export(wav_buffer, format="wav")
|
| 262 |
-
# audio_bytes = wav_buffer.getvalue()
|
| 263 |
-
# st.info("Ensured audio is in WAV format.")
|
| 264 |
-
# except Exception as e:
|
| 265 |
-
# st.warning(f"Could not process recorded audio with pydub: {e}. Sending as is.")
|
| 266 |
-
|
| 267 |
-
|
| 268 |
# --- ADDED Logic for Default Example ---
|
| 269 |
elif input_method == "Use Default Example (Customer support call)":
|
| 270 |
default_file_path = DEFAULT_AUDIO_FILENAME
|
|
|
|
| 224 |
# --- ADDED "Use Default Example" option ---
|
| 225 |
input_method = st.radio(
|
| 226 |
"Choose audio input method:",
|
| 227 |
+
("Upload WAV file", "Use Default Example (Customer support call)"),
|
| 228 |
index=0,
|
| 229 |
key="input_method"
|
| 230 |
)
|
|
|
|
| 236 |
audio_bytes = uploaded_file.getvalue()
|
| 237 |
st.audio(audio_bytes, format='audio/wav')
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
# --- ADDED Logic for Default Example ---
|
| 240 |
elif input_method == "Use Default Example (Customer support call)":
|
| 241 |
default_file_path = DEFAULT_AUDIO_FILENAME
|