Skip to main content

A Cython wrapper for codec2

Project description

Pycodec2

Pycodec2 is a Cython wrapper for Codec 2.

In other words, Pycodec2 allows using the Codec 2 C library from Python.

Installation

Prerequisites

Pycodec2 requires Codec 2.

On Linux, I recommend using the distro's package-manager, e.g., on Arch/Manjaro: pacman -Syuu codec2, so that Codec2's assets land in standard searchable directories for python setup.py to use.

On macOS, you may use the Homebrew formula.

Instructions

You can install the library using PyPI (the easiest option) or from source.

From PyPI

To install the library from PyPI, run:

pip install pycodec2

From Source

To install the library from source, see building instructions in DEV.md. You can then install the wheel with:

pip install dist/*.whl

Codec 2 Compatibility

Pycodec2 3.* is compatible with Codec 2 1.2.*.

Pycodec2 2.* is compatible with Codec 2 1.0.*.

Pycodec2 1.0.* is compatible with Codec 2 at 0.9.2+ versions.

If your Codec 2 version is older than 0.9.2, then try pycodec2-old package.

For more information on potential compatibility problems, check out this issue.

Usage

Example

example.py implements a basic script that uses Codec 2 to encode and deencode a sample. Use the following steps to run an end-2-end scenario (dev/rune2etest implements steps 2-5).

  1. Download a sample .wav file, e.g., trashcan.

  2. Convert the .wav to a raw mono-channel 8kHz format, e.g.,

    sox trashcan.wav -e signed-integer -b 16 trashcan.raw channels 1 rate 8000

  3. Compile pycodec2

    python setup.py build_ext --inplace

  4. Run example.py

    python example.py trashcan.raw

  5. Convert output.raw

    sox -r 8000 -e signed-integer -b 16 output.raw output.wav

Now you can listen to output.wav.

Expected Input Format

Codec 2 assumes that input files use:

  • 8kHz bitrate,
  • 16-bit width samples,
  • a single channel.

Available Modes

For a list of currently supported modes, look for _modes in pycodec2/pycodec2.pyx.

Remarks

This library is considered complete. Please notify me or send a pull request on GitHub if you notice any bugs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycodec2-3.0.0.tar.gz (94.6 kB view hashes)

Uploaded Source

Built Distributions

pycodec2-3.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (407.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pycodec2-3.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (826.3 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pycodec2-3.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (657.8 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pycodec2-3.0.0-cp312-cp312-macosx_10_9_x86_64.whl (835.7 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

pycodec2-3.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (646.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pycodec2-3.0.0-cp311-cp311-macosx_10_9_x86_64.whl (835.3 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pycodec2-3.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (614.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pycodec2-3.0.0-cp310-cp310-macosx_10_9_x86_64.whl (834.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pycodec2-3.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (617.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pycodec2-3.0.0-cp39-cp39-macosx_10_9_x86_64.whl (835.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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