Skip to main content

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.AudioSegment objects
  • Flexible Output: Convert loaded audio to:
    • pydub.AudioSegment objects
    • NumPy arrays
    • Local file paths (.wav, .mp3, etc.)
    • Base64 encoded strings
    • Data URLs
  • Automatic Input Type Detection: In most cases, loadaudio can 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loadaudio-1.0.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

loadaudio-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

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

Hashes for loadaudio-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2f5c51e5171a5aec23cbf0d86bc8095e4b3a6a98af2437212cedfdc6997caacd
MD5 5f38ce031c7566f25551beb8a8fd86dd
BLAKE2b-256 060d4bba4ce420848cbd22d60d4ce4ede04757e7c67c3ceff4041040a6841767

See more details on using hashes here.

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

Hashes for loadaudio-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 129fe1b71c59e04ad595dac2a1ea82090801250efd1ba21cb9a048bf023e3565
MD5 1eac4f2c0abdad3aa1b052adbb39ec1b
BLAKE2b-256 5d4ab8104eda7bde86e0fd7dccff96b71f8459c913b3dcb70fbe81000f89bfeb

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