Coder Social home page Coder Social logo

audio-recorder-streamlit's People

Contributors

joooohan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

audio-recorder-streamlit's Issues

There appears to be no way to clear the audio from audio_recorder, even when clearing the caches

Here is my function 👍

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

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

Record audio

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.

How to save audio_bytes as .wav file

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")

recording stops automatically

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?

Start recording without clicking

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.