Skip to main content

discord-ext-songbird

GitHub License GitHub Release PyPI - Version PyPI - Python Version

A general-purpose voice backend for discord.py 2.7, powered by songbird and written in Rust: low-latency audio in and out of Discord voice channels for music bots, recorders, voice tools and bridges to other audio systems.

Highlights

  • SongbirdClient, a discord.VoiceProtocol: await channel.connect(cls=SongbirdClient).
  • Receive continuous, silence-filled, real-time-paced per-user or mixed streams in the format you need (8–48 kHz, mono/stereo, PCM16 / f32 / µ-law / A-law, 10–1000 ms chunks; Discord's native 48 kHz stereo PCM16 by default), with speaking events, timestamps and drop accounting. Chunks are zero-copy buffers (bytes(chunk), memoryview(chunk), NumPy, Arrow).
  • Send realtime PCM with backpressure, wall-clock gap filling from source timestamps, and interruption (clear()) that is silent within 40 ms and reports how much of each tagged segment was actually played.
  • Files, raw PCM and Opus packets with a sequential queue; push-based encoded and Opus streams.
  • Leak-free and bounded by construction: Rust never holds a Python object, no Rust thread ever enters the interpreter, and every buffer has a validated cap.
  • CPython 3.14 and free-threaded 3.14t wheels.

Installation

pip install discord-ext-songbird
# or
uv add discord-ext-songbird

pyarrow integration is optional: pip install "discord-ext-songbird[arrow]".

Quick start

import os

import discord
from discord.ext import songbird

client = discord.Client(intents=discord.Intents.default())


@client.event
async def on_ready() -> None:
    channel = client.get_channel(int(os.environ["CHANNEL_ID"]))
    assert isinstance(channel, discord.VoiceChannel)
    vc = await songbird.connect(channel, config=songbird.VoiceConfig.low_latency())

    # Play a file…
    vc.play(await songbird.load_audio_file("hello.mp3"))

    # …and echo the channel back, 20 ms at a time (48 kHz stereo PCM16 by default).
    async with vc.listen_mixed() as mic, vc.open_playback() as out:
        async for chunk in mic:
            if chunk.speaking:
                out.write_nowait(chunk)


client.run(os.environ["DISCORD_BOT_TOKEN"])

Streaming to an external service (a speech recogniser, a realtime speech service, another voice system) uses the same two calls with the format and chunk size that service expects; see Streaming to external services and examples/websocket_bridge.py.

Documentation

Examples

File What it shows
examples/echo.py Receive + playback streaming: a member's voice played back with a delay
examples/websocket_bridge.py Generic bridge: raw PCM chunks out as binary WebSocket frames, returned audio played back, "clear" interrupts
examples/record.py One timeline-aligned WAV per user plus a speaking-event log
examples/music.py Music bot on the track queue, including queued HTTP streams
examples/lfm2_audio/ Japanese speech-to-text, read-aloud and realtime voice chat bots on a local speech model (LFM2.5-Audio-1.5B-JP); extra setup in its README

Set DISCORD_BOT_TOKEN (plus BRIDGE_URL for the bridge) and run e.g. python examples/record.py.

Development

Requirements: Rust (stable), uv, just. The native build also needs Opus: either libopus found by pkg-config (apt install libopus-dev pkg-config, brew install opus pkg-config) or CMake, with which the bundled Opus source is built. just test-fake needs neither Rust nor Opus.

uv sync --all-extras --dev --no-install-project   # dev dependencies
just test-fake                                   # Python tests on the pure-Python fake (no build)
just dev                                         # stubs + uv run --no-sync maturin develop
just test                                        # Rust tests + fake + real-module tests (test hooks)
just fmt && just check                           # format; clippy, invariants, ruff, ty (installs editable first if needed)

The workspace has two crates: crates/sbcore (all logic; no pyo3 dependency, tested with cargo test -p sbcore) and the binding crate at the root (discord_ext_songbird_native, built by maturin into discord.ext.songbird.native). The Python layer lives in py-src/discord/ext/songbird/. See docs/design.md for the design.

License

MIT. See LICENSE.

Metadata

Release files for discord-ext-songbird 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for discord-ext-songbird 0.6.0
File Size Uploaded Provenance Actions
discord_ext_songbird-0.6.0.tar.gz 688.4 kB Without provenance Details for discord_ext_songbird-0.6.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for discord-ext-songbird 0.6.0
File Actions
discord_ext_songbird-0.6.0-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for discord_ext_songbird-0.6.0-cp314-cp314t-win_amd64.whl
discord_ext_songbird-0.6.0-cp314-cp314t-win32.whl CPython 3.14 CPython 3.14 free-threading Windows x86-32 Details for discord_ext_songbird-0.6.0-cp314-cp314t-win32.whl
discord_ext_songbird-0.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 Details for discord_ext_songbird-0.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl
discord_ext_songbird-0.6.0-cp314-cp314t-musllinux_1_2_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ ARM64 Details for discord_ext_songbird-0.6.0-cp314-cp314t-musllinux_1_2_aarch64.whl
discord_ext_songbird-0.6.0-cp314-cp314t-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 Details for discord_ext_songbird-0.6.0-cp314-cp314t-manylinux_2_28_x86_64.whl
discord_ext_songbird-0.6.0-cp314-cp314t-manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64 Details for discord_ext_songbird-0.6.0-cp314-cp314t-manylinux_2_28_aarch64.whl
discord_ext_songbird-0.6.0-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for discord_ext_songbird-0.6.0-cp314-cp314t-macosx_11_0_arm64.whl
discord_ext_songbird-0.6.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for discord_ext_songbird-0.6.0-cp314-cp314-win_amd64.whl
discord_ext_songbird-0.6.0-cp314-cp314-win32.whl CPython 3.14 CPython 3.14 Windows x86-32 Details for discord_ext_songbird-0.6.0-cp314-cp314-win32.whl
discord_ext_songbird-0.6.0-cp314-cp314-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 Linux musl 1.2+ x86-64 Details for discord_ext_songbird-0.6.0-cp314-cp314-musllinux_1_2_x86_64.whl
discord_ext_songbird-0.6.0-cp314-cp314-musllinux_1_2_aarch64.whl CPython 3.14 CPython 3.14 Linux musl 1.2+ ARM64 Details for discord_ext_songbird-0.6.0-cp314-cp314-musllinux_1_2_aarch64.whl
discord_ext_songbird-0.6.0-cp314-cp314-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64 Details for discord_ext_songbird-0.6.0-cp314-cp314-manylinux_2_28_x86_64.whl
discord_ext_songbird-0.6.0-cp314-cp314-manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ ARM64 Details for discord_ext_songbird-0.6.0-cp314-cp314-manylinux_2_28_aarch64.whl
discord_ext_songbird-0.6.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for discord_ext_songbird-0.6.0-cp314-cp314-macosx_11_0_arm64.whl

Total release size: 95.9 MB

Release files / discord_ext_songbird-0.6.0.tar.gz

Download URL discord_ext_songbird-0.6.0.tar.gz
Size 688.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6986230a2129145b20f791a3546a3b7e35ddbc81d2540ae9ae0a6fafc56b3e3b
BLAKE2b-256 checksum
How to use checksums
a2e6d2369e36da199252ed846cb2c2bad2463a3758b202357af577097e0b938b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314t-win_amd64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314t-win_amd64.whl
Size 7.0 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
930472925d9944ee239e654740c263199b552d6a8db81691674d729000fdad08
BLAKE2b-256 checksum
How to use checksums
7d4151ff6d7732e64cbbc4af565f39cf3ff6df3eed0d2f3fc9b5ab4c0154571a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314t-win32.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314t-win32.whl
Size 6.1 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-32
SHA-256 checksum
How to use checksums
b20431e0944587b9537010107b67b30711e84a7391da634ea7d8edd787fca25f
BLAKE2b-256 checksum
How to use checksums
1a8036fba5ad9ff5652682b8e03ca3edf5ebe1ed15badcfae9c3407452cea4ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Size 7.5 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
8da00bfe8cd30259e8ea80ad91326a8de2de79e2ad1bbb46e6dc63f7d7bae4e4
BLAKE2b-256 checksum
How to use checksums
a323018f4a52f1ef11c98ad06dc6a85926e057b15c28c3b9f049196f8179f98a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314t-musllinux_1_2_aarch64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314t-musllinux_1_2_aarch64.whl
Size 6.9 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ ARM64
SHA-256 checksum
How to use checksums
660a15be07e94768f7cd33de47ff4659336d63fc959d098f8d07eae210c1ba30
BLAKE2b-256 checksum
How to use checksums
1051be616a0d5e1cb402b001f841d026e421d0fa9605c1f44bd26240d7b7c8f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314t-manylinux_2_28_x86_64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314t-manylinux_2_28_x86_64.whl
Size 7.2 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
00bb4f5d9863a415be2aa9cb28a6cbe7b6bf431513bb98ec6f58e60219494c28
BLAKE2b-256 checksum
How to use checksums
d8e0331e6046d343a2f943f4484f17e1eedbba13221e3547f885d9fe52e61473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314t-manylinux_2_28_aarch64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314t-manylinux_2_28_aarch64.whl
Size 6.7 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
eb8658cc1de29b12075f786370ca0e95253e3431553c63d78c2e69f3d1c71057
BLAKE2b-256 checksum
How to use checksums
4f7a00203ccca61e76a45200783d13eff53e4da6b803e96099a40a854f599bef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314t-macosx_11_0_arm64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314t-macosx_11_0_arm64.whl
Size 6.2 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
081d3bfefcf1791ea57551677710f35d3c7630b490e7397080eb1605750f28c8
BLAKE2b-256 checksum
How to use checksums
9e12720728ad636916acb545480b7765006803b85c488f2fb13401f7ef02e34d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314-win_amd64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314-win_amd64.whl
Size 7.0 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
890ebbbf6e81b98901d2718d5af5f602d54f45af54f8020ab2fd16ba98b0c5fa
BLAKE2b-256 checksum
How to use checksums
ab5b3f874f1faf309fcd49e0165de8555d806fe156dadcf123a5186eb3ef70d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314-win32.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314-win32.whl
Size 6.1 MB
Tags CPython 3.14 Windows x86-32
SHA-256 checksum
How to use checksums
b567bee96be178cbdfdf2857ea05b1893acc376bdc31b8aeb8459d9c9a1d9f86
BLAKE2b-256 checksum
How to use checksums
9931dd3be77e888648da948480ef5409bd00ff8eb26f777db59668bf7f313412
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314-musllinux_1_2_x86_64.whl
Size 7.5 MB
Tags CPython 3.14 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
016102b1c3f114647d65311b87ce3c6adac9541a7998fdcbc292cfc70afe385b
BLAKE2b-256 checksum
How to use checksums
ad564dc93d5330ef0ad19f1c3acb4e4252fb4535b3389fe434f0daf7080685e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314-musllinux_1_2_aarch64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314-musllinux_1_2_aarch64.whl
Size 6.9 MB
Tags CPython 3.14 Linux musl 1.2+ ARM64
SHA-256 checksum
How to use checksums
ea59c46ec37c447dc6bad7840da2f369fd1179b9bf6f9d8ce2a30f2840ee39a5
BLAKE2b-256 checksum
How to use checksums
4e7936372c81feb565d5abaacb1336acdf6c87d8f0fc72146b52da1a60f9a9e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314-manylinux_2_28_x86_64.whl
Size 7.2 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3b9a10a162ac78cfbb9936e0ae7c4a62d9c2b9de30f6b09b4be31863d4d0b6ce
BLAKE2b-256 checksum
How to use checksums
0cecec63487eb090a1da43b89bbb9dc05421c0c7cc5f41722feb552ad21aae2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314-manylinux_2_28_aarch64.whl
Size 6.7 MB
Tags CPython 3.14 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
9c11d6c67c5c1d7e82096cd1d7f2e3322418ea713e395500b1b88c43c4e50864
BLAKE2b-256 checksum
How to use checksums
360f5aab02999375ca8d80d2cf27c44db73aa4d08caeb1c8ed90457dbd82114d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / discord_ext_songbird-0.6.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL discord_ext_songbird-0.6.0-cp314-cp314-macosx_11_0_arm64.whl
Size 6.2 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9767ef0553b24e0ee5e3bd7dd0ef808bcbffa4bc9e421a0478abcf7cc8145a6c
BLAKE2b-256 checksum
How to use checksums
a05dc15871804586382edbb5998ddb4480e65ae811ec46f8cba09c3a0ac9a866
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Security for discord-ext-songbird 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page