Skip to main content

A Python library to log audio files and their spectrograms into a single HTML file for easy inspection.

Reason this release was yanked:

bug

Project description

wavetable

PyPI Version

wavetable_banner


A Python library for generating organized HTML tables of audio samples, waveforms, and spectrograms. wavetable allows you to compare "Generated" vs "Ground Truth" audio directly in your browser or Jupyter Notebook with zero-dependency static HTML output.

Features

  • Static HTML Output: Generates self-contained (embedded) or lightweight (linked assets) HTML files.
  • Visualizations: Automatic Waveform and Spectrogram (STFT or Mel) display.
  • Comparisons: Native support for displaying reference audio.
  • Customizable: Control colormaps, frequency scales (Log/Mel/Linear), and magnitude scaling (dB/Linear).

Installation

pip install wavetable # if using pip
poetry add wavetable # if using poetry
...

Quick Start

import numpy as np
from wavetable import AudioLogger

logger = AudioLogger(name="my_experiment",
                     sr=44100,
                     root_dir="audio_logs",
                     save_mode="embed" # or "link"
                    )

# Dummy Audio
audio_gen = np.sin(2 * np.pi * 440 * np.linspace(0, 2, 44100*2))
audio_gt  = np.sin(2 * np.pi * 440 * np.linspace(0, 2, 44100*2)) + 0.1

# Log a cell
logger.log(
    row="Epoch_1",
    col="Sample_A",
    audio=audio_gen,
    ground_truth=audio_gt,
    meta="Loss: 0.02"  # Text metadata displayed above the cell
)

# Save to disk (creates audio_logs/my_experiment.html)
save_path = logger.save()

# Optional: Display in Jupyter Notebook
logger.display()

Check out test_notebook.ipynb for a the visual output or download the example HTML file (demo.html).

Configuration

You can customize the logger by passing a plot_config dictionary during initialization. The full configuration options available in the file wavetable/config.py.

1. General Settings

Parameter Type Default Description
sr int 44100 Global sampling rate.
save_mode str 'embed' 'embed' (single huge HTML file) or 'link' (HTML + assets folder).
hover_effect bool True Highlights the active row on mouse hover.
root_dir str 'audio_logs' Directory where logs are saved.

2. Spectrogram Configuration

Passed via plot_config={'spectrogram': {...}}:

Parameter Options Default Description
spectrogram_type 'stft', 'mel' 'stft' The type of spectrogram to compute.
plot_freq_scale 'log', 'linear' 'log' Y-axis scaling (only used if type is 'stft').
magnitude_scale 'db', 'linear' 'db' Compression of magnitude/power.
n_mels int 80 Number of Mel bands (only used if type is 'mel').
cmap str 'inferno' Matplotlib colormap name (e.g., 'viridis', 'magma').
n_fft int 2048 FFT window size.
hop_length int 512 STFT hop length.

3. Waveform Configuration

Passed via plot_config={'waveform': {...}}:

Parameter Type Default Description
overlay_gt bool False If True, plots Ground Truth signal behind Generated signal.
color_gen str '#007bff' Hex color for Generated audio (Blue).
color_gt str '#fd7e14' Hex color for Ground Truth audio (Orange).
ylim tuple (-1, 1) Y-axis limits for the waveform plot.

Advanced Example

logger = AudioLogger(
    name="Mel_Spectrogram_Test",
    sr=22050,
    hover_effect=False, # Disable row highlighting
    plot_config={
        'spectrogram': {
            'spectrogram_type': 'mel',
            'n_mels': 128,
            'magnitude_scale': 'db',
            'cmap': 'magma',
            'dimensions': (300, 80) # W, H in pixels
        },
        'waveform': {
            'overlay_gt': True,     # See Gen and GT on top of each other
            'dimensions': (300, 40)
        }
    }
)

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

wavetable-0.1.4.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

wavetable-0.1.4-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file wavetable-0.1.4.tar.gz.

File metadata

  • Download URL: wavetable-0.1.4.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for wavetable-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f06e2eeb7cca8c1a5cf19c31384d3bd7016e0adc27a2d6b606e1059716e770f1
MD5 85dfa8558f4d85b7762e9318f65178d7
BLAKE2b-256 d565e672a14bfe02eba195e62466f7d4cf9da053730f0c7ea4b10d12fcb56645

See more details on using hashes here.

File details

Details for the file wavetable-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: wavetable-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for wavetable-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7a5b49369f237154fb97d72a7a68e507d3ed45863cc5b3c411cc5ba4127fb2c0
MD5 3b3acf7f0a19965a325fdade10f08e37
BLAKE2b-256 c0cc84c03e045d763d6116934e836271a045e68e6d13b2f5b9e54a4cd796970f

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