Skip to main content

audioman

Python library for manipulating audio files. This can be used for editing audio, or tagging audio.

Installation

Install audioman using pip

pip install audioman

Audio

Audio editing here is done using the audio samples represented in a numpy array. Although, it is easy to combine audio together without touching the samples.

First we load the audio.

from audioman import Audio

audio = Audio('audio.wav')

Or we can load using raw samples

import numpy
from audioman import Audio

audio = Audio(numpy.array([[0,0,0,0,0]]), sample_rate = 4400)

Once you're done modifying the audio file, you can save it.

audio.save('modified.wav')

If you don't specify a filename, it will use self.filename, but since that is usually lost when modifying the audio, it's best to specify the filename anyway.

Audio objects are can be combined

from audioman import Audio

audio1 = Audio('audio1.wav')
audio2 = Audio('audio2.wav')

audio3 = audio1 + audio2

len(audio3) # len(audio1) + len(audio2)

You can also increase the gain.

audio = Audio('audio.wav')
audio2 = audio + 5

The original audio object does not get modified.

Trimming audio is also easy.

audio = Audio('audio.wav')
trimmed = audio.trim(start = 0, length = audio.seconds_to_samples(3))

Of course if you only specify the length, the start will be assumed to be 0.

trimmed = audio.trim(audio.seconds_to_samples(3))
trimmed.samples_to_seconds(len(trimmed)) # 3.0

If you wish to, you can also split the audio in 2 audio tracks.

audio1, audio2 = audio.split()

By default it will split in half, but you can specify the middle.

audio1, audio2 = audio.split(audio.seconds_to_samples(3))

If you wish to do so, you can add silence to an audio track.

audio2 = audio.add_silence(start = 0, length = audio.seconds_to_samples(3))

Of course if you want to add to the end, you can use -1

audio2 = audio.add_silence(start = -1, length = audio.seconds_to_samples(3))

If you omit start, it will set it to 0.

audio2 = audio.add_silence(audio.seconds_to_samples(3))

If you need to mix (overlay) two audio tracks together, use the .mix() method.

audio = Audio('audio.wav')
drums = Audio('drums.wav')

mixed = audio.mix(drums)

Effects

There are effects that you can apply to audio. Currently the only effect is an adjustable fade, but you can make your own easily.

To use effects, create an effect object, and apply the options.

from audioman import Audio
from audioman.effect import AdjustableFade

audio = Audio('audio.wav')

fade = AdjustableFade(length = audio.seconds_to_samples(3), gain0 = 0, gain1 = 1, fade_adjust = -1)
faded = audio.apply_effect(fade, start = audio.seconds_to_samples(-3))

You can find all the options for an effect in the .OPTIONS property.

from audioman.effect import AdjustableFade

print(AdjustableFade.OPTIONS)

""" stdout:
{
    'gain0': {
        'default': 1,
        'type': float,
    },
    'gain1': {
        'default': 0,
        'type': float,
    },
    'curve_ratio': {
        'default': 0,
        'type': float,
    }
}
"""

Metadata

Release files for audioman 1.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 audioman 1.1.0
File Size Uploaded
audioman-1.1.0.tar.gz 53.7 kB Details

Built distribution (wheel)

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

Total release size: 96.4 kB

Release files / audioman-1.1.0.tar.gz

Download URL audioman-1.1.0.tar.gz
Size 53.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a534825c32da040228bb20b98dae53f6ab6414907bbea8423e338f861b67c02b
BLAKE2b-256 checksum
How to use checksums
4b10dd3c211a1d9aa7168366721c01c22b213227c4364bc9fe3b2d1582054cd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / audioman-1.1.0-py3-none-any.whl

Download URL audioman-1.1.0-py3-none-any.whl
Size 42.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eba050829d0b1d633ea72f9dc8ace56de413b15d4fc55edec60097b50f05ed9d
BLAKE2b-256 checksum
How to use checksums
a65808a52028240deda6cacc98eda7bdba0192b021fb45efe9dbd4ffdcae4c96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

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