Skip to main content

Audio record streamlit

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

recorder.png

Installation

pip install audio-recorder-streamlit

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).
  • auto_start: If True starts the recording as soon as the component has loaded.
# 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,
)

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-0.0.10.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audio_recorder_streamlit-0.0.10-py3-none-any.whl (3.7 MB view details)

Uploaded Python 3

File details

Details for the file audio_recorder_streamlit-0.0.10.tar.gz.

File metadata

File hashes

Hashes for audio_recorder_streamlit-0.0.10.tar.gz
Algorithm Hash digest
SHA256 18dacee4c9bf3083a0e03058aff9e95e949cbf191ab0ec0213b6af88d7c429a6
MD5 795b378db3f4edab8f02dc51e8bbe636
BLAKE2b-256 ab9958f61ad44ac7c9f3d37cdcff768f283e2bc5ac7bacccb047288204f83fa5

See more details on using hashes here.

File details

Details for the file audio_recorder_streamlit-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for audio_recorder_streamlit-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 cc5e77d11d2c19e1f170b9e022acf75138e75b7dd239df37c4aeade5ec22b3b5
MD5 e7aeb5e7efa3de2a7207467020d4de2b
BLAKE2b-256 319d04b94f1b90efa99c036307e65c5670e96ef0af116c4b780b27a56e97ec82

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page