Skip to main content

streamlit-mic-recorder

Streamlit component that allows to record mono audio from the user's microphone, and/or perform speech recognition directly.

Installation instructions

$ pip install streamlit-mic-recorder

Usage instructions

Two functions are provided (with the same front-end):

audio=mic_recorder(
    start_prompt="Start recording",
    stop_prompt="Stop recording", 
    just_once=False,
    use_container_width=False,
    key=None
)

Renders a button. Click to start recording, click to stop. Returns None or a dictionary with the following structure:

{
    "bytes":audio_bytes, # wav audio bytes mono signal, can be processed directly by st.audio
    "sample_rate":sample_rate, # depends on your browser's audio configuration
    "sample_width":sample_width # 2
}

sample_rate and sample_width are provided in case you need them for further audio processing.

Arguments:

  • start/stop_prompt, the prompts appearing on the button depending on its recording state.
  • 'just_once' determines if the widget returns the audio only once just after it has been recorded (and then None), or on every rerun of the app. Useful to avoid reprocessing the same audio twice.
  • 'use_container_width' just like for st.button, determines if the button fills its container width or not.
text=speech_to_text(
    language='en',
    start_prompt="Start recording",
    stop_prompt="Stop recording", 
    just_once=False,
    use_container_width=False,
    key=None
)

Renders a button. Click to start recording, click to stop. Returns None or a text transcription of the recorded speech in the chosen language.

Example

import streamlit as st
from streamlit_mic_recorder import mic_recorder,speech_to_text

state=st.session_state

if 'text_received' not in state:
    state.text_received=[]

c1,c2=st.columns(2)
with c1:
    st.write("Convert speech to text:")
with c2:
    text=speech_to_text(language='en',use_container_width=True,just_once=True,key='STT')

if text:       
    state.text_received.append(text)

for text in state.text_received:
    st.text(text)

st.write("Record your voice, and play the recorded audio:")
audio=mic_recorder(start_prompt="⏺️",stop_prompt="⏹️",key='recorder')

if audio:       
    st.audio(audio['bytes'])

Release files for streamlit-mic-recorder 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-mic-recorder 0.0.2
File Size Uploaded
streamlit_mic_recorder-0.0.2.tar.gz 470.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-mic-recorder 0.0.2
File Interpreter ABI Platform
streamlit_mic_recorder-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size:945.5 kB

Release files / streamlit_mic_recorder-0.0.2.tar.gz

Download URL streamlit_mic_recorder-0.0.2.tar.gz
Size 470.6 kB
Tags Source
SHA-256 checksum
How to use checksums
115ecd7e526315afc6c7231859e2aa038f388a296fa0d7bbf791d857003d8b54
BLAKE2b-256 checksum
How to use checksums
b3f3d293057024d4ac642d988bcdf0b6d26202395ebee10ed51e3135f0dcd041
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / streamlit_mic_recorder-0.0.2-py3-none-any.whl

Download URL streamlit_mic_recorder-0.0.2-py3-none-any.whl
Size 474.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e09e63ffe503976e2fd24e16ef2ee3666bae83f18c5bd13f2345e41bfbb6cea
BLAKE2b-256 checksum
How to use checksums
28c866185fa15c9980ed50cc45f4341a9bf169fcc757753dc549e6c62781bd76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page