I tried it locally with 1.45.1 and this worked fine for me:
from pathlib import Path
import streamlit as st
audio_value = st.audio_input("Record a voice message")
if audio_value:
st.audio(audio_value)
audio_path = Path("audio.wav")
audio_path.write_bytes(audio_value.read())
st.write("Audio saved to audio.wav")
For some reason, this doesn’t work on my setup… I reinstalled Streamlit and rebooted too. Maybe, I am doing something wrong…
Here’s the video wherein I copy-pasted your code in tst.py and ran it. It accepts the voice input but gets into an infinite loop when you stop recording, to save.