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

Uploaded CPython 3.8+ Windows x86-64

rpaudio-0.0.15-cp38-abi3-win32.whl (910.3 kB view details)

Uploaded CPython 3.8+ Windows x86

rpaudio-0.0.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

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

rpaudio-0.0.15-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.15-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.15-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.15-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: rpaudio-0.0.15-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 969.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.15-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6a06398f5528088846ceca29fcf26c60f9aca1afa9859bc0fe5bb0e28d202585
MD5 8319f4f0744e99827db45917240018a0
BLAKE2b-256 beb4ad337cab9b8006bfcca740a85d9473c370ba30e115e4cfdd372ca37e2c0c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rpaudio-0.0.15-cp38-abi3-win32.whl
  • Upload date:
  • Size: 910.3 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.15-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 375e0d873701ea4bc6a43a4c81f5fb5095b8b91ad9d5d3ab7659668ed8d2149b
MD5 4b20443ecdb1d465f37de33206adc225
BLAKE2b-256 0b65f1748f322508f0dcd11c0c4a88e0cba99e04942deaea704c40522a5f7cff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 173909ae2f992863f3d68023ee881cef15d10eec24797b0365fabb4e594374cb
MD5 0d2bc55d0ce9a1fa465bf271edb24339
BLAKE2b-256 6400a2e75432ec63716782c1a06aa8f09db9835abde3675536341457c09ecf42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.15-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 48a9e80d8b14b12c262b5719cb4eed757366707c9add1ae52af84a15cb95064a
MD5 4b1d3aa85d6e4f0176fa480e4a99d228
BLAKE2b-256 64c4bdf434c2ceef0b0b3035680bc6fe598b6659198223319365bb2a3c943f6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.15-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3bded14041068f1a36f3b267d0509213c162a1f75a94a1955e1cf75914de3529
MD5 3fe67d5ba45bdee5ed379b7a78fcf16e
BLAKE2b-256 3fe772f4dc49ff59c568ea0f14fd30b8bedad8c0ec1ed7119c794a4d156e27d8

See more details on using hashes here.

File details

Details for the file rpaudio-0.0.15-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.15-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 0656fe9c53fea4484bf82fa339823bdba6dd8775a8f408621b123aa0f7b930c7
MD5 ffda4a81390dce0f233c070a8d3ab4e0
BLAKE2b-256 c9d28663a57f6e277a1494c306116cd9be5db38865b9f114578616c78a39b74f

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