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

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

rpaudio-0.0.18-cp38-abi3-win_amd64.whl (993.3 kB view details)

Uploaded CPython 3.8+Windows x86-64

rpaudio-0.0.18-cp38-abi3-win32.whl (942.8 kB view details)

Uploaded CPython 3.8+Windows x86

rpaudio-0.0.18-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.18-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (1.8 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ i686

rpaudio-0.0.18-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.18-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-64macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for rpaudio-0.0.18-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cc4eacd17d7132278bbb30027c454a48939d2b95586d7a088bf7f912aeceb73a
MD5 62211ae1a5aa70e5eefb2e25ed032c33
BLAKE2b-256 22469c3485bed2a9d024b9b6d1ecbfa843fa7b911b177cc605c62e2d525f6a3f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rpaudio-0.0.18-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 0910ea6d9f10c338e210e40a0d03c2b0a644b2991c42eb7af0c2fd0b4b638c1a
MD5 220b98a40d5d8a9b477e6a0a8e230600
BLAKE2b-256 6d6ca1499fdc6049a56caf6082d6f77017b1087e6969b082857e99f3b78787ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.18-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9069eaf4af4e0bb7e4481cba9ab3dd5d2189308767e6a3e37ff7cb6202827e1
MD5 e73f0c21cd3e01b6eeedeabb46f7a2a3
BLAKE2b-256 d134b8e684a2955e37877e6f07d00e95e60eef672ef360783f9a5802cf50e664

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.18-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a8218f30957d7d3f12ba8c134688c8db0ea7dc19e5c73706c8d97f3d1567fd35
MD5 8d4ca2d1f0c0e620776e57beefaf70f2
BLAKE2b-256 4929ae8c144ee7ad433fee5e8f3afce32b101ed5153a773a62295747c181f5db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpaudio-0.0.18-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fb1fd4561bed772ba6d96157fc451edab97828b945016dea0901bdf3f6f61ae0
MD5 c66f0474bcacab40c97df582ae9d4eb2
BLAKE2b-256 813d18a8ff7af7d05edddb787e81d71a273eb93f21076ee3015befc7bb7ec16f

See more details on using hashes here.

File details

Details for the file rpaudio-0.0.18-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.18-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 0309110464a09be8243327355d8912d5d0895ee91910072accefc0f44716282a
MD5 a2481a5fa8006063bf9a0dc3d50f78fa
BLAKE2b-256 52ce161cea072ff64e28316c634624b8d7299e9fe72c33c661f5f83dfd9c7371

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