Skip to main content

speechwidgets

Jupyter widgets for speech processing

preview

Installation

You can install using pip:

pip install speechwidgets

If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable the nbextension:

jupyter nbextension enable --py [--sys-prefix|--user|--system] speechwidgets

Usage

from speechwidgets import SpectrogramPlayer

Basic usage:

SpectrogramPlayer(
    wav_file_path='./19-198-0001.wav',
    width=800,
    spec_height=200,
    navigator=True,
    nav_height=60,
)

Advanced usage:

SpectrogramPlayer(
    wav_file_path='./19-198-0001.wav',
    width=800,
    spec_height=200,
    navigator=False,
    settings=False,
    colormap="greys",

    # for dark mode notebooks:
    dark=False, # set to True
    transparent=False, # optionally set to True
    
    # mel spec parameters:
    n_fft=2048,
    win_length=400,
    hop_length=160,
    f_min=50, 
    n_mels=80,
    power=1.0,
    
    # amplitude to db parameter:
    top_db=80 
)

Annotations:

word_intervals = [['0.54', '0.84', 'this'],
        ['0.84', '1.1', 'little'],
        ['1.1', '1.4', 'work']]
s = SpectrogramPlayer(
    wav_file_path='./19-198-0001.wav',
    width=800,
    spec_height=200
)
s.annotate(data=word_intervals, title="Word Intervals", height=20, stroke_width=0.5)

You can call the annotate method multiple times with different data. title, height and stroke_width are optional arguments.

See examples/ folder on github for full code examples.

Development Installation

Create a dev environment:

conda create -n speechwidgets-dev -c conda-forge nodejs python=3.10 jupyterlab
conda activate speechwidgets-dev

Install the python dependencies. This will also build the TS package.

pip install -e ".[test, examples]"

When developing your extensions, you need to manually enable your extensions with the notebook / lab frontend. For lab, this is done by the command:

jupyter labextension develop --overwrite .
npm install
npm run build

For classic notebook, you need to run:

jupyter nbextension install --sys-prefix --symlink --overwrite --py speechwidgets
jupyter nbextension enable --sys-prefix --py speechwidgets

Note that the --symlink flag doesn't work on Windows, so you will here have to run the install command every time that you rebuild your extension. For certain installations you might also need another flag instead of --sys-prefix, but we won't cover the meaning of those flags here.

How to see your changes

Typescript:

If you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the widget.

# Watch the source directory in one terminal, automatically rebuilding when needed
npm run watch
# Run JupyterLab in another terminal
jupyter lab

After a change wait for the build to finish and then refresh your browser and the changes should take effect.

Python:

If you make a change to the python code then you will need to restart the notebook kernel to have it take effect.

Metadata

Release files for speechwidgets 1.0.1

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

Source distribution (sdist)

Source distribution for speechwidgets 1.0.1
File Size Uploaded Provenance
speechwidgets-1.0.1.tar.gz 758.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for speechwidgets 1.0.1
File Interpreter ABI Platform
speechwidgets-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 1.3 MB

Release files / speechwidgets-1.0.1.tar.gz

Download URL speechwidgets-1.0.1.tar.gz
Size 758.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d970c05692991a82f2a9cf0215ebd071a618631d0b663fbcb3bb1e2b73bbdd6f
BLAKE2b-256 checksum
How to use checksums
28c473b4e66a2ffd3ff36bbfd73ff978a463a6ea54f2717fd1e909043fb6bb5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / speechwidgets-1.0.1-py2.py3-none-any.whl

Download URL speechwidgets-1.0.1-py2.py3-none-any.whl
Size 514.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2b4816c34239b91f9a530d81e1fe68e7c72b9cbae2a55ab329b086f17cc16803
BLAKE2b-256 checksum
How to use checksums
e3c8da39cd0112dd247f1399a7a7c1f444f90f0765b8568503c8f8bfbedd2be2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for speechwidgets 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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