Skip to main content

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.1.0 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

Metadata

Release files for soundpython 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for soundpython 0.1.11
File Size Uploaded
soundpython-0.1.11.tar.gz 14.3 kB Details

Built distribution (wheel)

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

Total release size: 27.8 kB

Release files / soundpython-0.1.11.tar.gz

Download URL soundpython-0.1.11.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fae0315ff8c851b2daef2c0ae655f4ced5312a2139c5851a01f44c67a803c0e0
BLAKE2b-256 checksum
How to use checksums
ad97af41516bd935e348db805de22ec4f95dab4605869354040ba62b2325b345
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.28

Release files / soundpython-0.1.11-py3-none-any.whl

Download URL soundpython-0.1.11-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fac6d0870c61927dfe26b4b6b3e6672f46954d728592a06ce73bf0a37e77604d
BLAKE2b-256 checksum
How to use checksums
3f576d3e3a92d4a913a3003b74eadd08afd8535b006408787a9f9d0fd3a801ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.28

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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