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.0.0.tar.gz (51.9 kB view details)

Uploaded Source

Built Distribution

audioman-1.0.0-py3-none-any.whl (40.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for audioman-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5144f5a28f19551d6d2890aa0aff131de4272dbc11df9b9767ce6bba24370969
MD5 7694ae4aa96ba8b85e1c459e9db41d7f
BLAKE2b-256 72dc60bea4cc23a258fda4e9126b926370296797fc3e847018973443d4488740

See more details on using hashes here.

File details

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

File metadata

  • Download URL: audioman-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 40.5 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6805eef80dbca97743776ad9ffc8c57a2c2e116acfc3398b058ce42e4caf620b
MD5 1edc35212fce122330ab11aff24ac135
BLAKE2b-256 97501d729074ff8cfeeb0f7e6f5adada3242add2a29b08d0a007ef89a7f312bf

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