npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-audio-spectrogram-player

v1.0.1

Published

An audioplayer written in React that shows a spectrogram along with the audio.

Downloads

43

Readme

react-audio-spectrogram-player

An audioplayer written in React that shows a spectrogram along with the audio. The playhead on the spectrogram is synchronized with the audioplayer. You can zoom in on the spectrogram and slow down the audio. It acts almost as a microscope for audio.

Note: At the moment, you still need to compute the spectrogram yourself and pass it to the component via the src prop.

If you use Python, there is also a jupyter widged based on this component. You can find it here.

Preview

See the demo.

preview

Installation

npm i react-audio-spectrogram-player

Usage

Basic Usage

import SpectrogramPlayer from "react-audio-spectrogram-player";

...

const App = () => {

    const src = ... // string: path to wav file

    const sxx = ... // number[][]: 2D array with spectrogram values

    return (
        <SpectrogramPlayer
            src={src}
            sxx={sxx}
        />
    )
}

Customization

return (
    <SpectrogramPlayer
        src={src}
        sxx={sxx}
        specHeight={200}
        navHeight={50}
        navigator
        settings
        colormap="viridis"
        transparent
        dark
    />
)

|Prop|Type|Default|Description| |---|---|---|---| |src|string|required|Path to the wav audio file.| |sxx|number[][]|required|2D array with spectrogram values.| |specHeight|number|200|Height of the main spectrogram.| |navigator|boolean|false|Allow user to zoom in with the navigator UI.| |navHeight|number|50|Height of the navigator UI.| |settings|boolean|false|Allow user to change some playback behaviour.| |colormap|string|'viridis'|The colormap to use.| |transparent|boolean|false|Use rgba values for spectrogram image.| |dark|boolean|false|Use dark mode theme.|

Annotations

You can annotate intervals (such as words or phones) below the spectrogram.

  1. First place your annotation data in one or more (string | number)[][] objects.

    • Column 1: Start time in seconds
    • Column 2: End time in seconds
    • Column 3: Annotation as a string

    For example:

    const wordIntervals = [
        [0.54, 0.84, "this"],
        [0.84,  1.1, "little"],
        [ 1.1,  1.4, "work"],
        ...
    ]
    const phoneIntervals = [
        [0.54, 0.62, "ð"],
        [0.62, 0.67, "ɪ"],
        [0.67, 0.84, "s"],
        ...
    ]
  2. Now create a list of annotation objects that will be passed to the component:

    const annotations = [
        {
            data: wordIntervals,
            title: "Word intervals:",
            height: 30,
            strokeWidth: 1,
        },
        {
            data: phoneIntervals,
            title: "Phone intervals:",
            height: 30,
            strokeWidth: 1,
        }
    ]

    The title, height and strokewidth entries are optional.

  3. Pass the list to the component via the annotations prop:

    return (
        <SpectrogramPlayer
            src={src}
            sxx={sxx}
            specHeight={200}
            navHeight={50}
            annotations={annotations}
        />
    )

Future Updates

  • Calculate spectrogram with javascript when no sxx prop is supplied.
  • Better touch screen compatibility.