Skip to main content

Simple audio processing library.

Project description

soundpython

soundpython is a Python library for audio file processing that provides a simple, intuitive interface for working with audio data. It supports various audio formats and offers functionality for both mono and stereo audio manipulation.

Features

  • Load and save audio in multiple formats (MP3, WAV, OGG, FLAC)
  • Convert between mono and stereo audio
  • Manipulate individual audio channels
  • Extract portions of audio by time
  • Concatenate audio files with optional crossfade
  • Create smooth audio transitions with crossfading overlay
  • Automatic audio normalization
  • Comprehensive metadata handling

Requirements

  • Python 3.10 or higher
  • NumPy 2.2.1 or higher
  • FFmpeg (must be installed and available in system PATH)

Installation

Install the package using pip:

pip install soundpython

Usage

Here are some common usage examples:

from soundpython import Audio

# Load an audio file
audio = Audio.from_file("song.mp3")

# Convert stereo to mono
mono_audio = audio.to_mono()

# Extract left channel from stereo audio
left_channel = audio.get_channel(0)

# Extract portions of audio by time
intro = audio.slice(end_seconds=30.0)  # First 30 seconds
chorus = audio.slice(60.0, 90.0)       # 30-second clip from 1:00 to 1:30
outro = audio.slice(180.0)             # Everything after 3:00

# Simple concatenation of audio segments
combined = intro.concat(chorus)

# Crossfade between two audio segments
# The end of intro will fade out while the start of outro fades in
crossfaded = intro.overlay(outro, fade_duration=2.0)  # 2-second crossfade

# Create silent tracks
stereo_silence = Audio.create_silent(duration_seconds=5.0)  # 5 seconds of stereo silence
mono_silence = Audio.create_silent(duration_seconds=3.0, stereo=False)  # 3 seconds of mono silence

# Save in different formats
audio.save("output.wav")
audio.save("output.mp3")

Audio Metadata

The library provides detailed metadata about audio files through the AudioMetadata class:

# Access audio metadata
print(f"Sample rate: {audio.metadata.sample_rate}Hz")
print(f"Channels: {audio.metadata.channels}")
print(f"Duration: {audio.metadata.duration_seconds:.2f}s")
print(f"Bit depth: {audio.metadata.bits_per_sample} bits")

Development

To set up the development environment:

  1. Install uv
  2. Clone the repository
  3. Install development dependencies:
uv sync --dev
  1. Run tests:
uv run pytest

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

soundpython-0.1.3.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

soundpython-0.1.3-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file soundpython-0.1.3.tar.gz.

File metadata

  • Download URL: soundpython-0.1.3.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.28

File hashes

Hashes for soundpython-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1430be7ee52273e8b4191be24cd5e8bf3707f75b93a1815a0beb8afa7019c088
MD5 d2c269a4aca13923d8ec5bd795b1c0d6
BLAKE2b-256 3ad1a390630bfe7fa2c04fca3b7c9428eee4e07aa8ca34c8f7a11859dc23c25b

See more details on using hashes here.

File details

Details for the file soundpython-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for soundpython-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1f8760b94c1393a21228399dc6bbca48acbe97fb66d0444a0279c88ac82394dc
MD5 1c315d3295cc5c342a58a22f7701dbb4
BLAKE2b-256 8371abf76f6d17f7cfced19123694baf5d2cdf3d36147324b3b0e3bdd7d1dde1

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