Skip to main content

Rust audio api binding for python

Project description

Pytest Version

rpaudio

rpaudio is a Rust-based Python library for handling audio operations, designed to provide simple and efficient audio management. It leverages Rust's performance and concurrency safety to offer a robust solution for Python audio applications.

API

  • AudioSink: Simple audio access and control for individual files.
  • AudioChannel: Handle and process audio files in a queue via channels.
  • ChannelManager: Multi-channel grouping and management.
  • AudioSink.metadata Access information about audio files if present.
  • Effects : FadeIn, FadeOut, ChangeSpeed

Supports: MP3, WAV, Vorbis and Flac (mp4 + AAC will also be supported in a future release)

Python 3.8+

Example Projects

FastAPI LAN Audio Web Client

Getting Started (Read the Docs)

import rpaudio
import asyncio
from rpaudio import FadeIn, FadeOut, ChangeSpeed

kill_audio = False
AUDIO_FILE = r"C:\Users\16145\Desktop\code_24\frpaudio\rpaudio\examples\ex.wav"


def on_audio_stop():
    global kill_audio
    kill_audio = True
    print("Audio has stopped")


async def play_audio():
    handler = rpaudio.AudioSink(callback=on_audio_stop).load_audio(AUDIO_FILE)
    print(handler.metadata)

    fade_in_effect = FadeIn(start_val=0.0, end_val=1.0, duration=3.0)
    fade_out_effect = FadeOut(duration=2.0)
    speed_up = ChangeSpeed(apply_after=1.0, end_val=0.8, duration=3.0)

    effects_list = [fade_in_effect,  fade_out_effect, speed_up]
    handler.apply_effects(effects_list)

    handler.play()


    while not kill_audio:
        await asyncio.sleep(1)


async def sleep_loop():
    global kill_audio
    i = 0
    while not kill_audio:
        await asyncio.sleep(1)
        i += 1


async def main():
    await asyncio.gather(play_audio(), sleep_loop())

asyncio.run(main())

OS Dependency Installation Instructions

Windows

No additional OS-level dependencies are required for rpaudio on Windows. Ensure you have the latest version of Python installed, and you can directly use pip to install the library:

pip install rpaudio

macOS

To install rpaudio on macOS, you need to install gettext:

Install gettext:

brew install gettext
brew link gettext --force

Linux

To install rpaudio on Linux, you may need to install some dependencies based on your distribution:

For Debian/Ubuntu-based distributions:

sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev

For Red Hat/CentOS-based distributions:

sudo yum install -y pkg-config alsa-lib-devel

After installing the necessary OS-level dependencies, you can install rpaudio using pip:

pip install rpaudio

Contributing

Please read CONTRIBUTING.md for guidelines on how to contribute.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

rpaudio-0.0.16-cp38-abi3-win_amd64.whl (957.8 kB view details)

Uploaded CPython 3.8+ Windows x86-64

rpaudio-0.0.16-cp38-abi3-win32.whl (914.6 kB view details)

Uploaded CPython 3.8+ Windows x86

rpaudio-0.0.16-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

rpaudio-0.0.16-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (1.7 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686

rpaudio-0.0.16-cp38-abi3-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

rpaudio-0.0.16-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.2 MB view details)

Uploaded CPython 3.8+ macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

File details

Details for the file rpaudio-0.0.16-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: rpaudio-0.0.16-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 957.8 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for rpaudio-0.0.16-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 737e728d83fe5ba9a6d3e3f09871b6d186d279e4340b27667e4901df8be5e0d7
MD5 cd70bf4cb9e48ee789093af663c7b7c6
BLAKE2b-256 828e296d754ac4c9b2ea60f80494e9e976480b3644f208886390707cc8fb33bb

See more details on using hashes here.

File details

Details for the file rpaudio-0.0.16-cp38-abi3-win32.whl.

File metadata

  • Download URL: rpaudio-0.0.16-cp38-abi3-win32.whl
  • Upload date:
  • Size: 914.6 kB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for rpaudio-0.0.16-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 3a0720d08fab95d6023d6dbb3e6cf4bc5e3b8c74a8fad22137dc02d348dfb7b4
MD5 7c94e3965866454e0da7ecb716291657
BLAKE2b-256 92420eb15859bb266c75fcfa1ed5e90289194b70ccbc5abf8af2fb6a7ae737d5

See more details on using hashes here.

File details

Details for the file rpaudio-0.0.16-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rpaudio-0.0.16-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4670b2b7d76746f5ea723a63134d9fa1f145c10f28436c5d0cce53b802e0e674
MD5 5907c3f0d4bf88b4f78fa5adedd3e69a
BLAKE2b-256 7f24510ca133d9811eba53a36f8fc0ae9015bf4771687119c70e20bdf64f1538

See more details on using hashes here.

File details

Details for the file rpaudio-0.0.16-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for rpaudio-0.0.16-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 07c2e1d00644adb4cd172c9230f5408d32e56a719dc7460b07b5db12b175e237
MD5 53dde9ff90bae0ef43db40150c4e47b5
BLAKE2b-256 806407011d7946518b7c155ec7597ed4b2af71ff6fad414c216cbcdaba7e1597

See more details on using hashes here.

File details

Details for the file rpaudio-0.0.16-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rpaudio-0.0.16-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a934f66e3f7cfc0db42cefc0faa231a1267ac7a2135fba0c0d1aabb2022e63e0
MD5 3d01a77eafc85bb064ddee206347064a
BLAKE2b-256 86896baa75d8b6d78d068cab0203c28fe63928bee5050a46b446dcbe36e3d008

See more details on using hashes here.

File details

Details for the file rpaudio-0.0.16-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rpaudio-0.0.16-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 2c45b111f76bc52a9301da128fa78de5fe190c739a617f14eb3116b761813e95
MD5 88ae3102b172396c4cf753a5937aaeca
BLAKE2b-256 f84318fdd57d042efd35dd1ae96e8598c82966f87058042e80d15861ad52b24a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page