Skip to main content

AudioTensor

A torch.Tensor subclass that remembers the hop_length (samples per frame) of frame-based audio features, so tensors at different frame rates can be combined directly.

pip install audiotensor
import torch
from audiotensor import AudioTensor, interpolation_mode

f0 = AudioTensor(torch.randn(4, 100), hop_length=256)       # (B, T) at hop 256
loudness = AudioTensor(torch.randn(4, 400), hop_length=64)  # (B, T) at hop 64

x = f0 * loudness       # f0 is upsampled to hop 64 first
print(x.hop_length)     # 64

with interpolation_mode("cubic"):  # "linear" (default), "nearest", "cubic"
    y = f0 + loudness
  • Wrap your tensor as AudioTensor(tensor, hop_length) and use it as a regular tensor.
  • For ndim > 1, the shape is (B, T, ...), where B is the batch size and T is the number of frames.
  • Results with ndim < 2 (e.g. x.sum(), x[0]) have no time axis and get hop_length = -1.
  • Tensors with different hop_length are automatically resampled to the greatest common divisor of their hop_lengths and truncated to the shortest one when you combine them.
  • In-place operations (x += y, x.add_(y), ...) resample the other operands to x, never x itself, so x must have the finest hop_length.
  • hop_length always describes dim 1. Ops that move or remove that axis (transpose, reshape, ...) keep the hop_length unchanged, so use as_tensor() first if that is not what you want.
  • set_hop_length(hop_length) resamples the tensor to the new hop_length.
  • reduce_hop_length() upsamples the tensor to hop_length = 1.
  • steps returns the size of T in the tensor.
  • truncate(steps) truncates the tensor to the given steps.
  • unfold(size, step) returns a view of the tensor with a sliding window of size size and step step along the T dimension.
  • as_tensor() returns a plain torch.Tensor.

Metadata

Release files for audiotensor 0.1.0

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

Source distribution (sdist)

Source distribution for audiotensor 0.1.0
File Size Uploaded Provenance
audiotensor-0.1.0.tar.gz 13.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for audiotensor 0.1.0
File Interpreter ABI Platform
audiotensor-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / audiotensor-0.1.0.tar.gz

Download URL audiotensor-0.1.0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
098cd77031016b63cb7ecf7736b14f3898f0051ffca6ec1f38eb09a8fd1e4ac0
BLAKE2b-256 checksum
How to use checksums
764dd6a9718872573d6a7866ecd400804ce6527dd7ae10c069ab891987722ca4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / audiotensor-0.1.0-py3-none-any.whl

Download URL audiotensor-0.1.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d91266f5cff16426d4d374309a79680fa7f9e1455c469b572365587f74f68c6b
BLAKE2b-256 checksum
How to use checksums
41f5418661efbbaedb54f3a4598fb5cfa8383b7956c9a7459e95b0a1b8a97cbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for audiotensor 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for audiotensor-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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