Skip to main content

Streamlit component that allows you to do plot audio embeddings as a plotly figure with source audio playback on hover or click.

Project description

streamlit-audio-plot

Streamlit component that allows you to plot audio embeddings as a plotly figure with source audio playback on hover or click.

Installation instructions

pip install streamlit-audio-plot

Usage instructions

import streamlit as st

from audio_plot import audio_plot, Events

# minimal example
audio_plot(
    embeddings = [[0.1, 0.2], [0.3, 0.4]],
    urls = [
        "https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3#t=0.0,3.0",
        "https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3#t=60.0,63.0",
    ]
)  

# e.g. metadata is a pd.DataFrame
audio_plot(
    embeddings=metadata[["valence", "arousal"]],
    urls=metadata["urls"],
    labels=[f"{artist}: {title}" for artist, title in zip(metadata["artist"], metadata["title"])],
    event=Events.CLICK,  # or Events.HOVER
    height=800,
    volume=0.4,  # between 0. and 1.
    hidePlayer=true,
)

See the docstring for full specifications of parameters.

The JS audio playback requires that the user first interacts with the webpage (e.g. by clicking on the page). Otherwise, React with throw a runtime error that will replace the plot. This should be streamlined in the future to not require page reload.

Development instructions

Backend

python3.11 -m venv venv
source venv/bin/activate
pip install streamlit
streamlit run streamlit run audio_plot/__init__.py

Frontend (requires nvm or node.js)

cd audio_plot/frontend
nvm use
npm install
npm run start

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

streamlit-audio-plot-0.0.1.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

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

streamlit_audio_plot-0.0.1-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

Details for the file streamlit-audio-plot-0.0.1.tar.gz.

File metadata

  • Download URL: streamlit-audio-plot-0.0.1.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for streamlit-audio-plot-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c59041d59cf440ac10552c6b71f9daba4b531fd779e41e7122eee7fd47f84c2b
MD5 79ac6b2f2046bc7bf3d5662b1f6b9c86
BLAKE2b-256 9a37278e5e446b504a8f18fcbb227305b58c7ee2652d7fa6ae611de465c84320

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_audio_plot-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 312493e13759ebc18fb8738d7a4c37e677eeebc509277d4d41a4e730cd9e638b
MD5 516513b6cfa4e514bf371ec50e92888a
BLAKE2b-256 f59e03dc7fd10d3dcb74490ddd0e8950e4be82cfaf323744102b1ad7240edcd1

See more details on using hashes here.

Supported by

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