Closed gustavz closed 1 year ago
Hi @gustavz, you can get the sample_width using a third party library like wave
. I tried this and it seems to work:
import io
import wave
import streamlit as st
base_audio_bytes = audio_recorder(key="base")
if base_audio_bytes:
st.audio(base_audio_bytes, format="audio/wav")
buffer = io.BytesIO(base_audio_bytes)
with wave.open(buffer) as f:
st.write(f.getsampwidth())
What's the sample width of returned audio bytes? I want to convert the data into a
speech_recognition.AudioData
object which needssample_rate
andsample_width
defined. lib: https://github.com/Uberi/speech_recognition