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, ...), whereBis the batch size andTis the number of frames. - Results with
ndim < 2(e.g.x.sum(),x[0]) have no time axis and gethop_length = -1. - Tensors with different
hop_lengthare automatically resampled to the greatest common divisor of theirhop_lengths and truncated to the shortest one when you combine them. - In-place operations (
x += y,x.add_(y), ...) resample the other operands tox, neverxitself, soxmust have the finesthop_length. hop_lengthalways describes dim 1. Ops that move or remove that axis (transpose,reshape, ...) keep thehop_lengthunchanged, so useas_tensor()first if that is not what you want.set_hop_length(hop_length)resamples the tensor to the newhop_length.reduce_hop_length()upsamples the tensor tohop_length = 1.stepsreturns the size ofTin the tensor.truncate(steps)truncates the tensor to the givensteps.unfold(size, step)returns a view of the tensor with a sliding window of sizesizeand stepstepalong theTdimension.as_tensor()returns a plaintorch.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)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| audiotensor-0.1.0.tar.gz | 13.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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 logRelease 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 logSecurity 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.
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 logA 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.