Closed G1017 closed 4 months ago
This worked for me : if audio_bytes: st.audio(audio_bytes, format="audio/wav") with open(path_myrecording, mode='bw') as f: f.write(audio_bytes) f.close()
I think the problem on your code came from the audio_bytes that is in stereo. I think you are hearing the audio in "slow frame rate". May be the np.frombuffer is not not adapted for stereo.
I used this method, but there was a problem with the audio I saved.
import streamlit as st import numpy as np import soundfile as sf from audio_recorder_streamlit import audio_recorder
def save_audio(audio_bytes, output_file):
保存为 WAV 文件
audio_bytes = audio_recorder(sample_rate=44_100) if audio_bytes: save_audio(audio_bytes,'output.wav') st.audio(audio_bytes, format="audio/wav")