Skip to main content

No project description provided

Project description

Audio record streamlit

This streamlit component allows to register an audio utterence from a user.

recorder.png

Installation

pip install audio-recorder-streamlit-auto

Usage

import streamlit as st
from audio_recorder_streamlit import audio_recorder

audio_bytes = audio_recorder()
if audio_bytes:
    st.audio(audio_bytes, format="audio/wav")

Recording parameters

You can adjust the recording parameters energy_threshold and pause_threshold:

  • energy_threshold: The energy recording sensibility above which we consider that the user is speaking. If it is a float, then this is the energy threshold used to automatically detect recording start and recording end. You can provide a tuple for specifying different threshold for recording start detection and recording end detection.
  • pause_threshold: The number of seconds to spend below energy_level to automatically stop the recording.
  • sample_rate: Sample rate of the recorded audio. If not provided, this will use the default sample rate (https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/AudioContext).
# The recording will stop automatically
# 2 sec after the utterance end
audio_bytes = audio_recorder(pause_threshold=2.0, sample_rate=41_000)

Styling parameters

You can adjust the button style parameters:

audio_bytes = audio_recorder(
    text="",
    recording_color="#e8b62c",
    neutral_color="#6aa36f",
    icon_name="user",
    icon_size="6x",
)
custom.png

Frequently Asked Question

How can I record for a fixed duration ?

You can record for a fixed duration by setting the energy_threshold=(-1.0, 1.0) so that the recorder considers that you are speaking at the beginning and then you are never speaking from this point on.

Then simply set pause_threshold to your desired recording length.

# Records 3 seconds in any case
audio_bytes = audio_recorder(
  energy_threshold=(-1.0, 1.0),
  pause_threshold=3.0,
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audio-recorder-streamlit-auto-0.0.1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

File details

Details for the file audio-recorder-streamlit-auto-0.0.1.tar.gz.

File metadata

File hashes

Hashes for audio-recorder-streamlit-auto-0.0.1.tar.gz
Algorithm Hash digest
SHA256 14b36ff49e9afa1151e56c086457190945cfd171d14bdd403149f18d5a2f1adf
MD5 6f7ec49b39f19c6c06d95fe87238dd44
BLAKE2b-256 30c2b813ecd68d6956e2f33e114e267632e65bbf299386b0f96c8855af08da95

See more details on using hashes here.

File details

Details for the file audio_recorder_streamlit_auto-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for audio_recorder_streamlit_auto-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c96f8df4bcdbe45caa89a0fd81fb6de2e4ca07b3f027414123ef090042991dc
MD5 e4b4c7b6ba60c663db86f9fa5f695108
BLAKE2b-256 637da4190ca45b5a17660800af7ca3ee79df67aadc50b93f9e661580e7d705c5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page