Audio as mathematical data — collect, operate, transform, and export.
Project description
Phonotensor
Audio as mathematical data — collect, operate, transform, and export.
Phonotensor is a robust, well-typed Python library that treats audio not just as files, but as structured, manipulatable mathematical tensors. It provides a simple, fluent API for audio collection, mathematical manipulation (DSP), and deterministic playback with state-of-the-art OS-level permission management.
Features
- Deterministic Recording & Playback: Cross-platform stream management via
sounddeviceandportaudio. - Comprehensive Permission Model: Safe hardware and filesystem verification before resource acquisition.
- Fluent DSP Operators: Mix, concatenate, fade, filter, and modify volumes mathematically.
- Robustness: 100% strict type coverage and exhaustive automated testing.
Installation
Install Phonotensor via pip:
pip install phonotensor
(Optional) For MP3 support:
pip install phonotensor[mp3]
Quickstart
Here is a simple example to record 3 seconds from your microphone, generate a sine wave, mix them together, and play the result:
import numpy as np
from phonotensor import MicrophoneSource, AudioTensor, AudioPlayer, ops, fmt
# Initialize your microphone securely
mic = MicrophoneSource(sample_rate=44100, channels=1)
print("Recording for 3 seconds...")
audio = mic.record(duration=3.0)
# Generate a 440Hz sine wave tone
frequency = 440
tone = AudioTensor.from_function(
lambda t: 0.3 * np.sin(2 * np.pi * frequency * t),
duration=3.0,
sample_rate=44100,
)
# Math operations: Mixing the microphone signal with the tone
mixed = ops.mix([audio, tone], weights=[0.7, 0.3])
# Summarize the audio context
print(fmt.describe(mixed))
# Play it back
player = AudioPlayer()
player.play(mixed)
License
Copyright (c) 2026 Emberflock Labs (Owner: Ayush Jha). All rights reserved.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phonotensor-0.2.2.tar.gz.
File metadata
- Download URL: phonotensor-0.2.2.tar.gz
- Upload date:
- Size: 34.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2634833bd3795de2261564535c63aa88458a4f20f18d7b787fd2ee6c550c6b5e
|
|
| MD5 |
63108bb67592badb20f7f4d7aa33b4e4
|
|
| BLAKE2b-256 |
88074f284ad8ab02120b76ec038af5246f3a3ea79a417dd01b103c01c67f7686
|
File details
Details for the file phonotensor-0.2.2-py3-none-any.whl.
File metadata
- Download URL: phonotensor-0.2.2-py3-none-any.whl
- Upload date:
- Size: 37.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a21b308644c6bdf4db68c3fbc32f3895c4bc597729b493b70c9d3c0f3db7d5fd
|
|
| MD5 |
02774569dc3f989d7e431affcd381ff5
|
|
| BLAKE2b-256 |
b2134b7feb22678f2186a5e949af3c7948d0f50d8d38234a6379a6e24b4c3f0d
|