joooohan / audio-recorder-streamlit Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hello,
OpenAI whisper has 25 MB file limit. A mere 2 min, 30 secs audio exceeds that limit.
Is there any option to specify the bitrate so that I can store longer audios?
Thanks.
What's the sample width of returned audio bytes?
I want to convert the data into a speech_recognition.AudioData
object which needs sample_rate
and sample_width
defined.
lib: https://github.com/Uberi/speech_recognition
Here is my function 👍
def record_audio():
audio_data = audio_recorder(pause_threshold=3.0, sample_rate=48_000, icon_size="2x")
if audio_data:
st.audio(audio_data, format="audio/wav")
return audio_data
Each time the code is run it returns the previous recording. Is there any way to clear the recording once it is read ?
Reproducible Code Example:
from audio_recorder_streamlit import audio_recorder
def record_audio():
# Record audio
audio_data = audio_recorder(pause_threshold=3.0, sample_rate=48_000, icon_size="2x")
if audio_data:
st.audio(audio_data, format="audio/wav")
return audio_data
audio_data = record_audio()
The code runs when the streamlit audio button is pressed.
How do I only call record_audio() when a new sound has been recorded or clear the recording so that a null or "" is returned on subsequent reads or a flag tells me whether the record button has been pressed ?
Expected Behavior
I feel that a call to audio_recorder() should clear the sound, or there should be a way of detecting when the streamlit audio record button has been pressed.
Perhaps there is but I am missing something ?
Current Behavior:
The previous recording is always returned no matter how often this code is called.
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_array = np.frombuffer(audio_bytes, dtype=np.int16)
with sf.SoundFile(output_file, 'w', 44100, 1) as file:
file.write(audio_array)
audio_bytes = audio_recorder(sample_rate=44_100)
if audio_bytes:
save_audio(audio_bytes,'output.wav')
st.audio(audio_bytes, format="audio/wav")
Hi @Joooohan , thanks for this streamlit component!
Is it intended that it automatically stops recording after a few seconds (around 3-7)?
The length seems random and it is not possible to do longer recordings.
Any idea around that issue?
Is it possible to start a recording by simply calling on the function? I saw that you include an OnClick param for the react component, could it be possible without?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.