Skip to main content

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

Project description

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,
    }
}
"""

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

audioman-1.1.0.tar.gz (53.7 kB view details)

Uploaded Source

Built Distribution

audioman-1.1.0-py3-none-any.whl (42.7 kB view details)

Uploaded Python 3

File details

Details for the file audioman-1.1.0.tar.gz.

File metadata

  • Download URL: audioman-1.1.0.tar.gz
  • Upload date:
  • Size: 53.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for audioman-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a534825c32da040228bb20b98dae53f6ab6414907bbea8423e338f861b67c02b
MD5 a23696e9fbf273d976a9466f75268746
BLAKE2b-256 4b10dd3c211a1d9aa7168366721c01c22b213227c4364bc9fe3b2d1582054cd8

See more details on using hashes here.

File details

Details for the file audioman-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: audioman-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 42.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for audioman-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eba050829d0b1d633ea72f9dc8ace56de413b15d4fc55edec60097b50f05ed9d
MD5 6bfc1f279027bb5bfc1d27924ba2f105
BLAKE2b-256 a65808a52028240deda6cacc98eda7bdba0192b021fb45efe9dbd4ffdcae4c96

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page