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.1

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.1
File Size Uploaded Provenance Actions
discord_ext_songbird-0.6.1.tar.gz 694.3 kB Without provenance Details for discord_ext_songbird-0.6.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for discord-ext-songbird 0.6.1
File Actions
discord_ext_songbird-0.6.1-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for discord_ext_songbird-0.6.1-cp314-cp314t-win_amd64.whl
discord_ext_songbird-0.6.1-cp314-cp314t-win32.whl CPython 3.14 CPython 3.14 free-threading Windows x86-32 Details for discord_ext_songbird-0.6.1-cp314-cp314t-win32.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314t-musllinux_1_2_x86_64.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314t-musllinux_1_2_aarch64.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314t-manylinux_2_28_x86_64.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314t-manylinux_2_28_aarch64.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314t-macosx_11_0_arm64.whl
discord_ext_songbird-0.6.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for discord_ext_songbird-0.6.1-cp314-cp314-win_amd64.whl
discord_ext_songbird-0.6.1-cp314-cp314-win32.whl CPython 3.14 CPython 3.14 Windows x86-32 Details for discord_ext_songbird-0.6.1-cp314-cp314-win32.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314-musllinux_1_2_x86_64.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314-musllinux_1_2_aarch64.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314-manylinux_2_28_x86_64.whl
discord_ext_songbird-0.6.1-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.1-cp314-cp314-manylinux_2_28_aarch64.whl
discord_ext_songbird-0.6.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for discord_ext_songbird-0.6.1-cp314-cp314-macosx_11_0_arm64.whl

Total release size: 95.9 MB

Release files / discord_ext_songbird-0.6.1.tar.gz

Download URL discord_ext_songbird-0.6.1.tar.gz
Size 694.3 kB
Tags Source
SHA-256 checksum
How to use checksums
aefe8239319826ced54b8b51a56e7cbb8523796075c37a89a965ff20aa3a99ce
BLAKE2b-256 checksum
How to use checksums
cb2334bae6271afe096f7db5097e1e283ee3bcfe3e02b7abee3cf060e950ad95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
edacf456e8e4095e924362cfd2f3f361a46c5187e3416ad4d51d51e94bd22ab0
BLAKE2b-256 checksum
How to use checksums
756b831278ca7dee4b058db95ebeca8632432b425741b9db68afe4626ca7bad9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
829e9b59f8b3d699f94ae16c7b699fbab404ff02c7d518cd06c65f63ab34bdbd
BLAKE2b-256 checksum
How to use checksums
9caf3c66138376f97bffedb5668a2ce351260253e7d81e7e08288a8c360350d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
b4401c8e9c04e2edb5f4fed206b728bad2f8fa4d740cd5a2afb7ab1ba8f0db19
BLAKE2b-256 checksum
How to use checksums
f4dc9acb3127e0dcb8665f86ed3f041e0bc74722cd71274c1f51fd752d73d45d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
174b112fa60485b419805e5979f4bc9df966b9b8f03ca1f0e1945d31b17c56a7
BLAKE2b-256 checksum
How to use checksums
ca23f6ab463af61472d914b4ae2f9070871693a3c12a3ce0ee459f8f91b147ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
815f75ad6e509950a652b25e47ebf99db87a64a1ee632255b95265f96d18bfec
BLAKE2b-256 checksum
How to use checksums
3d917bf2a7c51cb6470eacd6ef88f20b24b5021bc29087354390d32bc19b9b71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
f99e689f3eb78d98e3d3044ab089f4fcea6c64a03139f71e8e527c2dad798172
BLAKE2b-256 checksum
How to use checksums
f134e3d28c97d140bef1591f2e000fadce7bcd445b9d152deae3ac175abda896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
4c746bb2bc283a34398e3697b7abc14a6001f81801c41135276b2943702780e3
BLAKE2b-256 checksum
How to use checksums
4d99c6ff786768ca6928d6d9f03c5b12b9d215d6abf57d431a4f2fe3ffc55a0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

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

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

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

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

Download URL discord_ext_songbird-0.6.1-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
b2d3e599ee59fb10369accce1ba02a2ff5ed807d6bfb55cf1aca3fc5ee93ee3c
BLAKE2b-256 checksum
How to use checksums
6d0a1b3329a06b054a0be04d6ee7cdc3f19ebe2df5ce7725b09e8e4fc4da14ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
af8d4015c1003910e90d67679161f15ae2d146216c2e78f6016896f6bf813b5b
BLAKE2b-256 checksum
How to use checksums
75eb43d49e1504ea0a99de1b6b95024be80c1625592ab843aea1518681c41fc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
8e05b7a655cc751e1b226fdeb931222c97068da55e5da218cf23297660f43e73
BLAKE2b-256 checksum
How to use checksums
9e086fd6c4a6cb9e03f9ac5d3b73b9ba8dfc8dd1217af206c8e8bca797a8f4ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
f8757d117c13312fc07c2cb4b4d3c11dd3f9777da498fe8c918f7bb7a126163c
BLAKE2b-256 checksum
How to use checksums
33e65aca53afb1efb2e4f3e6ca479a96a16616ff266efbc24dc41f68772c7019
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL discord_ext_songbird-0.6.1-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
e0cdfbd621f70085cfb13f7f7968c367dcd5132b822caa2188947ae96f0e8151
BLAKE2b-256 checksum
How to use checksums
2400d58452515a66a9dfc29b46bfac86690d1f75f0b82937a7775e6ae19187d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Security for discord-ext-songbird 0.6.1

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