Skip to main content

Audio Layers

Project description

yw

Audio Layers

To install: pip install yw

Overview

The yw package provides a comprehensive suite of tools for audio processing and manipulation in Python. It leverages popular libraries such as numpy, librosa, soundfile, and matplotlib to offer functionalities like audio file conversion, resampling, waveform manipulation, and audio visualization.

Features

  • Audio Conversion: Convert audio files to different formats and sample rates using convert_to_wav.
  • Waveform Manipulation: Functions to ensure mono audio, resample audio, and manipulate waveforms with operations like adding silence.
  • Audio Information Extraction: Retrieve detailed information from audio files, such as duration, sample rate, and format-specific data.
  • Audio Visualization: Plot waveforms and spectrograms to visualize audio data.
  • Sound Object: A Sound class that encapsulates audio data along with utility methods for easy manipulation and analysis.

Usage Examples

Converting Audio Files to WAV

Convert any audio file format supported by ffmpeg to WAV format with a specified sample rate:

from yw import convert_to_wav

convert_to_wav('input.mp3', 'output.wav', sample_rate=44100)

Extracting Audio File Information

Get detailed information from a WAV file:

from yw import sound_file_info_dict

info = sound_file_info_dict('example.wav')
print(info)

Plotting a Waveform

Visualize the waveform of an audio file:

from yw import display_sound

display_sound('path/to/audio.wav')

Working with the Sound Class

Create a Sound object from a file, manipulate it, and save the output:

from yw import Sound

sound = Sound.from_file('input.wav')
sound.resample(new_sr=22050)
sound.save_to_wav('output_resampled.wav')

Mixing Audio

Mix two audio files into one by adjusting their relative weights:

from yw import Sound

sound1 = Sound.from_file('audio1.wav')
sound2 = Sound.from_file('audio2.wav')
sound1.mix_in(sound2, weight=0.5)
sound1.save_to_wav('mixed_output.wav')

Documentation

Each function and class in the yw package comes with detailed docstrings that provide more information on their usage and parameters. Here are some key functions/classes and their purposes:

  • convert_to_wav(source_file, target_file=None, sample_rate=44100): Convert an audio file to WAV format.
  • sound_file_info_dict(filepath): Retrieve a dictionary containing information about the audio file.
  • display_sound(filepath): Plot and play an audio file.
  • Sound: A class that represents an audio signal, with methods like from_file, resample, mix_in, and save_to_wav for handling audio data.

For more detailed information, refer to the docstrings provided within the code.

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

yw-0.0.9.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

yw-0.0.9-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file yw-0.0.9.tar.gz.

File metadata

  • Download URL: yw-0.0.9.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for yw-0.0.9.tar.gz
Algorithm Hash digest
SHA256 ec568efcc989ac83fb99450c33fae91f73ebe7603922d6c9843909542e27d88b
MD5 02b53ba47f3e6b589e475f685f90fe34
BLAKE2b-256 0a199a46907ebbabc6bf08cd47be26cc51c3a952777874997bdec1fec7e18af2

See more details on using hashes here.

File details

Details for the file yw-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: yw-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for yw-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8f9aca1807411243d0d54c9dfa7f599853fc228f8e418fa01e2abf8cdaea8c70
MD5 20110bee42381c8bac6f6e413af585ef
BLAKE2b-256 e55e3c30bd57df32d2147602646b3bf57150b774463ceafbb56e660d47bbcd9f

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