Skip to main content

TorchAudio Forced Aligner

Project description

wavesurfer

PyPI License

A Python package for audio visualization and playback in Jupyter notebooks.

Features

  • Visualize audio waveforms in Jupyter notebooks
  • Support for various audio formats (WAV, MP3, FLAC, etc.)
  • Streaming audio playback for real-time applications
  • Programmatic control with play/pause functionality
  • Performance monitoring with latency and RTF metrics
  • Display alignment information on waveforms

Installation

pip install wavesurfer

Usage

Basic Playback

Play a wave file directly:

from wavesurfer import play

play("assets/test_16k.wav")

Play waveform data:

from audiolab import load_audio
from wavesurfer import play

audio, rate = load_audio("assets/test_16k.wav")
play(audio, rate)

Displaying Alignments

Display alignment information on the waveform:

from wavesurfer import play

# Play with alignment information from a TextGrid file
play("assets/test_16k.wav", alignments="assets/test_16k.TextGrid", config={"options": {"normalize": True}})

You can also provide alignments as a list of alignment items:

from wavesurfer import play

# Create alignment items
alignments = [
    {"start": 0.0, "end": 0.5, "content": "hello"},
    {"start": 0.5, "end": 1.0, "content": "world"},
]

# Play with alignment information
play("assets/test_16k.wav", alignments=alignments)

Streaming Playback

Play streaming waveform data:

import time
from audiolab import load_audio
from wavesurfer import play

def audio_generator():
    for frame, rate in load_audio("assets/test_16k.wav", frame_size_ms=300):
        time.sleep(0.1)  # RTF: 0.1 / 0.3 < 1
        yield frame

play(audio_generator(), 16000)

Programmatic Control

For more advanced usage, you can use the Player class directly to have programmatic control over playback:

from wavesurfer import Player

# Create a player instance
player = Player()

# Load audio
player.load("assets/test_16k.wav")

# Programmatically control playback
player.play()   # Start playback
player.pause()  # Pause playback

The Player class also supports all the audio formats that the play function supports, including file paths, waveform data, and streaming generators.

License

BSD 2-Clause License

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

wavesurfer-0.3.8.tar.gz (90.7 kB view details)

Uploaded Source

Built Distribution

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

wavesurfer-0.3.8-py3-none-any.whl (98.3 kB view details)

Uploaded Python 3

File details

Details for the file wavesurfer-0.3.8.tar.gz.

File metadata

  • Download URL: wavesurfer-0.3.8.tar.gz
  • Upload date:
  • Size: 90.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for wavesurfer-0.3.8.tar.gz
Algorithm Hash digest
SHA256 2be7fb0b4c62efe1b2dc51d718b1c71a9f6a2480480bea5dace472fff4e20cfe
MD5 5f2234c05ca6bfdad0b99a72e980ecef
BLAKE2b-256 ac3435fc460d1cbb0347b1214514eeb30db7a3b8716c79c19b25c9847bade95f

See more details on using hashes here.

File details

Details for the file wavesurfer-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: wavesurfer-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 98.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for wavesurfer-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a3e5618e4edb74a1c95638f84b43d35fc8bf25ad9d0638a24eb4ccc914189c8d
MD5 839182f0c767dda46f6da7cc773d8772
BLAKE2b-256 853ed1fa2e437b7d68e683564f06d4fb8a6f4601cc01b7433b8f7b63d7c4177a

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