Skip to main content

Audio processing.

Project description

hunterHearsPy

A comprehensive collection of Python utilities for audio processing.

Audio Processing Made Simple

Load and Save Audio Files

Read audio files with automatic stereo conversion and sample rate control:

from hunterHearsPy import readAudioFile, writeWAV

# Load audio with sample rate conversion
waveform = readAudioFile('input.wav', sampleRate=44100)

# Save in WAV format (always 32-bit float)
writeWAV('output.wav', waveform)

Process Multiple Audio Files at Once

Load and process batches of audio files:

from hunterHearsPy import loadWaveforms

# Load multiple files with consistent formatting
array_waveforms = loadWaveforms(['file1.wav', 'file2.wav', 'file3.wav'])

# The result is a unified array with shape (channels, samples, file_count)

Work with Spectrograms

Convert between waveforms and spectrograms:

from hunterHearsPy import stft, halfsine

# Create a spectrogram with a half-sine window
spectrogram = stft(waveform, windowingFunction=halfsine(1024))

# Convert back to a waveform
reconstructed = stft(spectrogram, inverse=True, lengthWaveform=original_length)

Process Audio in the Frequency Domain

Create functions that operate on spectrograms:

from hunterHearsPy import waveformSpectrogramWaveform

def boost_low_frequencies(spectrogram):
    # Boost frequencies below 500 Hz
    spectrogram[:, :10, :] *= 2.0
    return spectrogram

# Create a processor that handles the STFT/ISTFT automatically
processor = waveformSpectrogramWaveform(boost_low_frequencies)

# Apply the processor to a waveform
processed_waveform = processor(original_waveform)

Development

I want:

  • consistent waveforms,
  • consistent spectrograms, and
  • efficient, reliable transformations.

Therefore, I want one package, this package, to manage those objectives with a single source of truth for configurable universal settings.

  • I need good default universal settings.
  • I need an easy way to change a universal setting.
  • I want ad hoc overrides for some or all universal settings.

I don't know a good way to implement user-configurable universal settings. Therefore, as I normally do, I will use my HARDCODED system as a placeholder.

Semiotics

  • channel, rarely channels.
  • time is more generic than samples and often preferred.
  • array is generic.
  • when talking about a NumPy ndarray, write ndarray not array.
  • sampleRate is giving me problems in the "ingest" functions.
    • Regularly review these semiotics until the system is clear.
    • Most of the time, sampleRate is descriptive: this is the sample rate. See writeWAV.
    • In readAudioFile, the parameter is prescriptive: make this the sample rate. Even worse, the attribute of the current sample rate is readSoundFile.samplerate, which is descriptive, of course.
    • However, def resampleWaveform(waveform, sampleRateDesired: float, sampleRateSource: float): has excellent semiotics because it does not use sampleRate.

Preferred packages

  • NumPy
  • scipy
  • hunterMakesPy
  • tqdm (for status messages)
  • cytoolz via the Z0Z_tools package (until it finds a forever home)
  • more_itertools
  • astToolKit
  • pytest

Probably won't need

  • analyzeAudio
  • gmpy2
  • numba
  • platformdirs
  • sympy
  • torch-einops-kit

Not using PyTorch for "business" logic

  • But, I must have torch compatibility.
  • At a minimum, a transformation to and from torch that the user must call.
  • astToolkit easily creates real torch APIs and identifiers, however, for the windowingFunctions module in windowingFunctionsTensor.

Not using librosa

  • Dependency bloated.
  • Slow.
  • Less precise than I want.
  • I generally dislike the API and identifiers.

Disfavored packages

  • pandas

More vectorization

  • Few or no for loops.
  • Few or no for object comprehensions.

Installation

pip install hunterHearsPy

My recovery

Static Badge YouTube Channel Subscribers

CC-BY-NC-4.0

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

hunterhearspy-1.2.0.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

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

hunterhearspy-1.2.0-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file hunterhearspy-1.2.0.tar.gz.

File metadata

  • Download URL: hunterhearspy-1.2.0.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hunterhearspy-1.2.0.tar.gz
Algorithm Hash digest
SHA256 61fa7bfa58650c4f0de0f1c933fa16d267b159adbd63934466ebd616329c5da9
MD5 035e3c404adfd9c4c797fbcab402cd1e
BLAKE2b-256 ff2fbb5518d7e3a8fc32f4a0e1e741bcea9365ef7758f78a36e6d4bf52f71495

See more details on using hashes here.

File details

Details for the file hunterhearspy-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: hunterhearspy-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hunterhearspy-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b044c64702c5ac66795943ccb28c3a0b21c23aca7f412bdcf45c0fea95cddbe7
MD5 b372cb163bd539ec093fe2aabbf3ecc7
BLAKE2b-256 ac3cf14cb3dad832e46c54ed958053b98c20916caf5919d7de5704054e127c3e

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