GithubHelp home page GithubHelp logo

g711's Introduction

G711 A-Law / u-Law audio-coding library

The library is written as an extension for python3 and allows to work simply with G711 encoded audio.

Requirements

  1. Python 3.6+
  2. Numpy (will be installed anyway before the building procedure)
  3. Tools for building C/C++ applications (GCC/Clang/VS build tools)

Implementation details

The library is written in pure C and relies exclusively on a python build system. I tried to minimize the use of any platform-dependend functions to provide a truly cross-platform and fast library.

Installation

Source distribution is uploaded to PyPI, so just invoke pip install g711. Equivalently, you can clone code from https://github.com/stolpa4/g711 and then run pip install <path to cloned repo>.

Functions

  • load_alaw(path: Union[str, os.PathLike]) -> numpy.ndarray(dtype=numpy.float32) - Opens a file, loads its contents and decodes it from A-Law to float32 numpy array.
  • load_ulaw(path: Union[str, os.PathLike]) -> numpy.ndarray(dtype=numpy.float32) - Same for u-Law.
  • save_alaw(path: Union[str, os.PathLike], audio_data: numpy.ndarray(dtype=numpy.float32)) -> bool - Encodes an array to A-Law and writes bytes to a specified file. audio_data can be anything convertible to numpy.ndarray(dtype=numpy.float32).
  • save_ulaw(path: Union[str, os.PathLike], audio_data: numpy.ndarray(dtype=numpy.float32)) -> bool - Same for u-Law.
  • decode_alaw(encoded_bts: bytes) -> numpy.ndarray(dtype=numpy.float32) - Decodes raw A-Law bytes to float32 audio.
  • decode_ulaw(encoded_bts: bytes) -> numpy.ndarray(dtype=numpy.float32) - Same for u-Law.
  • encode_alaw(audio_data: numpy.ndarray(dtype=numpy.float32)) -> bytes - Encodes an array to A-Law and returns bytes object. audio_data can be anything convertible to numpy.ndarray(dtype=numpy.float32).
  • encode_ulaw(audio_data: numpy.ndarray(dtype=numpy.float32)) -> bytes - Same for u-Law.

g711's People

Contributors

stolpa4 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.