a python package to effortlessly load audio and convert audio to different formats.
Project description
loadaudio
loadaudio is a Python library designed to effortlessly load audio from a variety of sources and convert it to your desired format. Whether you're working with local files, remote URLs, base64 encoded strings, NumPy arrays, or pydub AudioSegment objects, loadaudio provides a simple and consistent interface.
Features
- Versatile Input: Load audio from:
- Local file paths (
.wav,.mp3, etc.) - URLs pointing to audio files
- Base64 encoded audio strings
- Data URLs (base64 encoded audio embedded in strings)
- NumPy arrays representing audio samples
pydub.AudioSegmentobjects
- Local file paths (
- Flexible Output: Convert loaded audio to:
pydub.AudioSegmentobjects- NumPy arrays
- Local file paths (
.wav,.mp3, etc.) - Base64 encoded strings
- Data URLs
- Automatic Input Type Detection: In most cases,
loadaudiocan automatically determine the input type, simplifying your code. - Handles Common Audio Formats: Supports a wide range of audio formats compatible with
pydub.
Installation
pip install loadaudio
Usage
from loadaudio import load_audio
import numpy as np
from pydub import AudioSegment
# Load audio from a file path as a pydub AudioSegment
audio_segment = load_audio("audio.wav", output_type="pydub")
# Load audio from a URL as a NumPy array
audio_numpy = load_audio("https://example.com/audio.mp3", output_type="numpy")
# Load a base64 string or data URL and save as a wav
file_path = load_audio("data:audio/wav;base64,...", output_type="file", output_path="output.wav")
# Load a NumPy array as a base64 string
numpy_array = np.array([1, 2, 3], dtype=np.int16) # Example data
base64_string = load_audio(numpy_array, output_type="base64")
# Load a pydub AudioSegment and get a data URL
pydub_segment = AudioSegment.from_file("another_audio.mp3")
data_url = load_audio(pydub_segment, output_type="dataUrl")
# Explicitly specify the input type (optional)
audio_from_base64 = load_audio("your_base64_string", output_type="pydub", input_type="base64")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loadaudio-1.0.0.tar.gz.
File metadata
- Download URL: loadaudio-1.0.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f5c51e5171a5aec23cbf0d86bc8095e4b3a6a98af2437212cedfdc6997caacd
|
|
| MD5 |
5f38ce031c7566f25551beb8a8fd86dd
|
|
| BLAKE2b-256 |
060d4bba4ce420848cbd22d60d4ce4ede04757e7c67c3ceff4041040a6841767
|
File details
Details for the file loadaudio-1.0.0-py3-none-any.whl.
File metadata
- Download URL: loadaudio-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
129fe1b71c59e04ad595dac2a1ea82090801250efd1ba21cb9a048bf023e3565
|
|
| MD5 |
1eac4f2c0abdad3aa1b052adbb39ec1b
|
|
| BLAKE2b-256 |
5d4ab8104eda7bde86e0fd7dccff96b71f8459c913b3dcb70fbe81000f89bfeb
|