Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
streamlit-audiorecorder
Advanced tools
Audio recorder component for streamlit.
It creates a button to start the recording and takes three arguments: the start button text, the stop button text, and the pause button text.
If the pause button text is not specified, the pause button is not displayed.
If all prompts are given as empty strings, the component will use the react-audio-recorder visualizer:
The signature of the component is:
audiorecorder(
start_prompt="Start recording",
stop_prompt="Stop recording",
pause_prompt="",
custom_style={'color': 'black'},
start_style={},
pause_style={},
stop_style={},
show_visualizer=True,
key=None):
The prompt parameters are self-explanatory.
The style parameters are dictionaries that allow you to customize the appearance of the buttons using CSS.
The custom_style
parameter is applied to all buttons, while the start_style
, pause_style
, and stop_style
parameters are applied only to the corresponding button.
The optional key
parameter is used internally by Streamlit to properly distinguish multiple audiorecorders on the page.
The show_visualizer
parameter is a boolean that determines whether to show live audio visualization while recording. If set to False, the text "recording" is displayed. It is used only when all prompts are empty strings.
The component's return value is a pydub AudioSegment
.
All AudioSegment
methods are available. In particular, you can:
st.audio(audio.export().read())
audio.export("audio.wav", format="wav")
pip install streamlit-audiorecorder
Note: This package uses ffmpeg, so it should be installed for this audiorecorder to work properly.
On Ubuntu/Debian: sudo apt update && sudo apt install ffmpeg
On Mac: brew install ffmpeg
import streamlit as st
from audiorecorder import audiorecorder
st.title("Audio Recorder")
audio = audiorecorder("Click to record", "Click to stop recording")
if len(audio) > 0:
# To play audio in frontend:
st.audio(audio.export().read())
# To save audio to a file, use pydub export method:
audio.export("audio.wav", format="wav")
# To get audio properties, use pydub AudioSegment properties:
st.write(f"Frame rate: {audio.frame_rate}, Frame width: {audio.frame_width}, Duration: {audio.duration_seconds} seconds")
Error: No record button is shown and you get the following error message in the console:
Component Error
Cannot read properties of undefined (reading 'getUserMedia')
Reason: To record the audio, this component uses the MediaDevices
interface.
For security reasons, the getUserMedia()
method is available only in secure contexts (HTTPS), as explained in the
MDM documentation :
As an API that may involve significant privacy concerns, getUserMedia()'s specification lays out a wide array of privacy and security requirements that browsers are obligated to meet.
getUserMedia() is a powerful feature that can only be used in secure contexts; in insecure contexts, navigator.mediaDevices is undefined, preventing access to getUserMedia(). A secure context is, in short, a page loaded using HTTPS or the file:/// URL scheme, or a page loaded from localhost.
Solution: Serve your website using HTTPS. If you are serving your website locally, make sure to access it using localhost
, not an IP address.
FAQs
Audio recorder component for streamlit
We found that streamlit-audiorecorder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.