Skip to main content

Optional NumPy backend for G.722 module

Project description

libg722

Build & Test

Introduction

The G.722 module is a bit exact implementation of the ITU G.722 specification for all three specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.

To allow fast and flexible interworking with narrow band telephony, the encoder and decoder support an option for the linear audio to be an 8k samples/second stream. In this mode the codec is considerably faster, and still fully compatible with wideband terminals using G.722.

History

The code was originally written by Milton Anderson milton@thumper.bellcore.com from BELLCORE, and has been modified by the Chengxiang Lu and Alex Hauptmann from the Speech Group, School of Computer Science, Carnegie Mellon University, to be fairly fast and efficient, while retaining high fidelity.

Steve Underwood steveu@coppice.org improved the code a lot later on and contributed it into several popular open source projects.

Himanshu Soni sonihimanshu@gmail.com has adjusted some coefficients to avoid over/under-flows in the decoder.

Phil Schatzmann phil.schatzmann@gmail.com has added cmake-glue and Arduino support.

Librarized by Sippy Software, Inc.

Build and Install library:

MacOS & Linux

git clone https://github.com/sippy/libg722.git
cmake -B libg722/build -S libg722
make -C libg722/build clean all test install

Note for macOS users: The library will be installed to ~/Library/libg722 by default. If you prefer a different location, you can specify it with:

cmake -B libg722/build -S libg722 -DCMAKE_INSTALL_PREFIX=/your/preferred/path

After installation, you may need to add the library path to your environment:

export DYLD_LIBRARY_PATH="$HOME/Library/libg722/lib:$DYLD_LIBRARY_PATH"

iOS

git clone https://github.com/sippy/libg722.git
cmake -B libg722/build-ios-device -S libg722 \
  -DCMAKE_SYSTEM_NAME=iOS \
  -DCMAKE_OSX_ARCHITECTURES=arm64 \
  -DCMAKE_OSX_SYSROOT=iphoneos \
  -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0
make -C libg722/build-ios-device

Install Python module from PyPy:

pip install G722

Build and Install Python module from source code:

git clone https://github.com/sippy/libg722.git
pip install libg722/

This builds the core package (G722) with no hard dependency on NumPy. To install NumPy decode support on demand:

pip install "G722[numpy]"

or:

pip install G722-numpy

LIBG722_BUILD_MODE controls build profile for the main G722 extension:

  • production: build with optimization (-O2, or /O2 on Windows).
  • debug: build with -g3 -O0.
  • auto (default): if . is a git repository and git is available, run git diff v{version} -- .; build in debug mode when it differs, otherwise production. If . is not a git repository or git is unavailable, use production.

LIBG722_PACKAGE_VARIANT controls which Python distribution is built from this repository:

  • core (default): builds/publishes G722.
  • numpy-addon: builds/publishes G722-numpy from python/G722_numpy_mod.c.

G722(sample_rate, bit_rate, use_numpy=None) accepts an optional use_numpy flag:

  • True: return NumPy arrays from decode() (raises if G722-numpy is not installed).
  • False: return Python array('h') from decode().
  • omitted: auto-detect the optional backend and use NumPy when available, otherwise array('h').

Pull library into your Docker container:

ARG BASE_IMAGE=debian:sid-slim
ARG LIBG722_IMAGE=sippylabs/libg722:latest-debian_sid-slim
FROM ${LIBG722_IMAGE} AS libg722
FROM ${BASE_IMAGE} AS build
COPY --from=libg722 /usr/local/lib/libg722.* /usr/local/lib/
COPY --from=libg722 /usr/local/include/g722* /usr/local/include/

License

This code is mostly Public Domain. Library test code is under BSD 2-clause license.

See LICENSE for copyright details and each individual file for specifics.

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

g722_numpy-1.2.5.tar.gz (19.7 kB view details)

Uploaded Source

File details

Details for the file g722_numpy-1.2.5.tar.gz.

File metadata

  • Download URL: g722_numpy-1.2.5.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for g722_numpy-1.2.5.tar.gz
Algorithm Hash digest
SHA256 645058406d818c38ac5d12c59f5161f5694bce762cb103a728a286f47246ee01
MD5 3d6878099391ed58d8af46568f8aadd7
BLAKE2b-256 447c83d89c61fd1bcb8089eb2665c88bbd4e998e58fe8c3fc99fbc3dd30eec8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for g722_numpy-1.2.5.tar.gz:

Publisher: build_and_test.yml on sippy/libg722

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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