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.17-cp38-abi3-win_amd64.whl (958.3 kB view details)

Uploaded CPython 3.8+ Windows x86-64

rpaudio-0.0.17-cp38-abi3-win32.whl (915.5 kB view details)

Uploaded CPython 3.8+ Windows x86

rpaudio-0.0.17-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.17-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.17-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.17-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.17-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: rpaudio-0.0.17-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 958.3 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.17-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6564d81fd724b4268bf5222fd0878cdb83c120d8a8709e00bea6f68e47dcb347
MD5 8ec626c38ddba7b9bd5de785b63e8076
BLAKE2b-256 f9bcb4f14f5105c6589ff0b9d3e5b6a6676caab67fcc59cf458ee2853c1a5123

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rpaudio-0.0.17-cp38-abi3-win32.whl
  • Upload date:
  • Size: 915.5 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.17-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 6b660695658970b1e8916f061fab4715e768e2b3e22fdcd85fe94f9fb6f079ca
MD5 5370ecd6cb3676d6271368940df5cd16
BLAKE2b-256 b416153233d1d39f6d3a6f25245c29f9f43242c69a1927d34fd49a4c5e48b248

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.17-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57ba0dab85752a83df8685e01c83bbfe57641ae38150e1c09980a7fa3fac4d03
MD5 a0d33e35eb45c604d4abf767a4e829aa
BLAKE2b-256 c80be94f5cc4a70aaf10c279222a999c7f8341bbb9923f017ecb61ffbcc00771

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.17-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 84ab066c2064f9562807ca5d63b85a914ed1fbdedf99061badca6658a1e8685b
MD5 489d71bb8436c83ad652af24527d1f5a
BLAKE2b-256 41d73b3ba99bf7ab6e57d02ee11d948e9e5c6cc216aec7cc06fcbf7a4ed76341

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.17-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f0e284d63c17270fd5ad35abe249fa93d23422e2017853c1ae7f1629a4aa5f50
MD5 18ebded60afe1efde765fc759f121994
BLAKE2b-256 df8ead95965233366e8823dd638f043db1028e2df3bb46db1f1c16b4a82fe071

See more details on using hashes here.

File details

Details for the file rpaudio-0.0.17-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.17-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 0c982730282d9a77221eaaad69bdd6823ead3a8f993ce5ee058f88de9a83e929
MD5 6d15bb1c4a25a98f461861738fe4be8a
BLAKE2b-256 c066ec792eeaeae14021d2175dd83e1682a131e5da69d1b6a3b220e029e84dcb

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