Skip to main content

A Streamlit component for displaying and interacting with audio waveforms.

Project description

Streamlit Wavesurfer Component

PyPI version

Forked and extended from PiotrDabkowski/streamlit_wavesurfer

A powerful, extensible Streamlit component for interactive audio waveform visualization and annotation, powered by wavesurfer.js.

Features

  • Customizable Waveform: Style the waveform and progress bar, set height, and more.
  • Regions: Add, edit, and remove regions with callbacks to Python. Supports region metadata and color mapping with colormap.
  • Keyboard Shortcuts: Nudge, play/pause, and and navigate regions with the keyboard for more for efficient annotation.
  • Plugin System: Enable/disable wavesurfer.js plugins (regions, spectrogram, timeline, zoom, hover, minimap, overlay) with type-safe configuration from Python.
  • Spectrogram View: Visualize audio frequency content (enable via plugin).
  • Extensible: Add your own plugins or overlays via my other project wavesurfer-overlay-plugin.
  • Numpy Audio Support: Load audio directly from numpy arrays or via popular python libs like librosa, pydub or soundfile.
  • Type-Safe, Modern React Frontend: Built with Jotai, shadcn/ui, and TailwindCSS.

Quickstart

1. Install

pip install streamlit-wavesurfer

2. Basic Usage

import streamlit as st
from streamlit_wavesurfer import wavesurfer, Region

# Define regions
regions = [
    Region(start=0, end=5, content="Intro"),
    Region(start=5, end=10, content="Verse"),
]

# Display the waveform
wavesurfer(
    audio_src="https://example.com/audio.mp3",
    regions=regions,
    plugins=["regions", "timeline", "zoom"],  # Enable desired plugins
    show_controls=True,
)

3. Advanced: Custom Plugin Configuration

from streamlit_wavesurfer import WaveSurferPluginConfiguration, OverlayPluginOptions

overlay_plugin = WaveSurferPluginConfiguration(
    name="overlay",
    options=OverlayPluginOptions(
        imageUrl="https://example.com/overlay.png",
        position="overlay",
        opacity=0.5,
    ),
)

wavesurfer(
    audio_src="https://example.com/audio.mp3",
    plugins=[overlay_plugin, "regions", "timeline"],
)

Supported Plugins

  • regions: Mark and annotate audio segments.
  • timeline: Show time notches and labels.
  • zoom: Zoom in/out of the waveform.
  • hover: Show time on hover.
  • minimap: Scrollbar-style mini waveform.
  • spectrogram: Frequency visualization.
  • overlay: Overlay images on the waveform.

See the wavesurfer.js plugin docs for details.

API

wavesurfer(...)

Argument Type Description
audio_src str URL or path to audio file (or base64/numpy, planned)
regions list List of Region or dicts
plugins list List of plugin names or WaveSurferPluginConfiguration
wave_options object Waveform display options
region_colormap str Colormap for region coloring
show_controls bool Show play/pause/skip controls
key str Streamlit component key

Returns:

  • The current state, including regions and last update timestamp.

Region

Region(start: float, end: float, content: str, id: Optional[str] = None, color: Optional[str] = None)

🛠️ Development

  • Frontend: React, TypeScript, Jotai, shadcn/ui, TailwindCSS
  • Backend: Python, Streamlit
  • Package manager: bun (not npm)

Build Frontend

cd streamlit_wavesurfer/frontend
bun install
bun run build

Run Example App

streamlit run streamlit_wavesurfer/__init__.py

Known Issues / TODO

  • Allow skipping to region/time from Python
  • Load audio from numpy arrays
  • Region validation from Python
  • Keyboard shortcuts require initial button press

See wavesurfer.js docs and Streamlit docs for more.


Contributions welcome!
LICENSE MIT
© 2025 Liam Power


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_wavesurfer-0.5.0.tar.gz (116.3 kB view details)

Uploaded Source

Built Distribution

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

streamlit_wavesurfer-0.5.0-py3-none-any.whl (115.6 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_wavesurfer-0.5.0.tar.gz.

File metadata

  • Download URL: streamlit_wavesurfer-0.5.0.tar.gz
  • Upload date:
  • Size: 116.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for streamlit_wavesurfer-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b70cf32dd5ba487cc576bb816f9e5409c36b3dbf37230b394cf90abd3e50c0e6
MD5 8ceda2082fe0ae58a065c447ff6fcdf7
BLAKE2b-256 f29abc347aeb68e63d5b69f477583bfcc6df8236a6aa908aaa868d3a9dcf32cc

See more details on using hashes here.

File details

Details for the file streamlit_wavesurfer-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: streamlit_wavesurfer-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 115.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for streamlit_wavesurfer-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b081f84784948a22721dddb45fc3b8ed425925ad82300ea1b220a0ed9b2bc7a
MD5 0ae00d41539250e64671da3db9e315dd
BLAKE2b-256 c7584d5dd63114d4e3718ddc5b4013b03e3c01430a352798e0eb212bb63c2121

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