Skip to content

python bindings for symphonia/opus - read various audio formats from python and write opus files

License

Notifications You must be signed in to change notification settings

kyutai-labs/sphn

Repository files navigation

sphn

Python bindings for the symphonia and opus crates.

  • Easily load various audio file formats into numpy arrays.
  • Read/write ogg/opus audio files with streaming support.

Installation

The python wheels are available on pypi.

pip install sphn

If you're seeing an issue with CMake saying "Compatibility with CMake < 3.5 has been removed from CMake.", this is because building Opus is not compatible with CMake 4.x. Install a 3.x version (e.g. 3.31) and then set the CMAKE environment variable to use it, e.g.:

pip install 'cmake<4' # Or use your system's package manager
CMAKE=/path/to/.venv/bin/cmake pip install sphn

Usage

Download some sample audio file.

wget https://github.com/metavoiceio/metavoice-src/raw/main/assets/bria.mp3
import sphn

# Read an audio file
data, sample_rate = sphn.read("bria.mp3")
print(data.shape, sample_rate)

# Save as wav
sphn.write_wav("bria.wav", data[0], sample_rate)

About

python bindings for symphonia/opus - read various audio formats from python and write opus files

Resources

License

Stars

Watchers

Forks

Packages

No packages published