Metadata-Version: 2.1
Name: speexdsp
Version: 0.1.0
Summary: Python bindings of speexdsp library
Home-page: https://github.com/xiongyihui/speexdsp-python
Author: Yihui Xiong
Author-email: yihui.xiong@hotmail.com
Maintainer: Yihui Xiong
Maintainer-email: yihui.xiong@hotmail.com
License: BSD
Download-URL: https://pypi.python.org/pypi/speexdsp
Description: speexdsp for python
        ===================
        
        [![Build Status](https://travis-ci.org/xiongyihui/speexdsp-python.svg?branch=master)](https://travis-ci.org/xiongyihui/speexdsp-python)
        
        ## Requirements
        + swig
        + compile toolchain
        + python
        + libspeexdsp-dev
        
        ## Build
        There are two ways to build the package.
        
        1. using setup.py
        
            ```
            sudo apt install libspeexdsp-dev
            git clone https://github.com/xiongyihui/speexdsp-python.git
            cd speexdsp-python
            python setup.py install
            ```
        
        2. using Makefile
        
            ```
            git clone https://github.com/xiongyihui/speexdsp-python.git
            cd speexdsp-python/src
            make
            ```
        
        ## Get started
        ```python
        """Acoustic Echo Cancellation for wav files."""
        
        import wave
        import sys
        from speexdsp import EchoCanceller
        
        
        if len(sys.argv) < 4:
            print('Usage: {} near.wav far.wav out.wav'.format(sys.argv[0]))
            sys.exit(1)
        
        
        frame_size = 256
        
        near = wave.open(sys.argv[1], 'rb')
        far = wave.open(sys.argv[2], 'rb')
        
        if near.getnchannels() > 1 or far.getnchannels() > 1:
            print('Only support mono channel')
            sys.exit(2)
        
        out = wave.open(sys.argv[3], 'wb')
        out.setnchannels(near.getnchannels())
        out.setsampwidth(near.getsampwidth())
        out.setframerate(near.getframerate())
        
        
        print('near - rate: {}, channels: {}, length: {}'.format(
                near.getframerate(),
                near.getnchannels(),
                near.getnframes() / near.getframerate()))
        print('far - rate: {}, channels: {}'.format(far.getframerate(), far.getnchannels()))
        
        
        
        echo_canceller = EchoCanceller.create(frame_size, 2048, near.getframerate())
        
        in_data_len = frame_size
        in_data_bytes = frame_size * 2
        out_data_len = frame_size
        out_data_bytes = frame_size * 2
        
        while True:
            in_data = near.readframes(in_data_len)
            out_data = far.readframes(out_data_len)
            if len(in_data) != in_data_bytes or len(out_data) != out_data_bytes:
                break
        
            in_data = echo_canceller.process(in_data, out_data)
        
            out.writeframes(in_data)
        
        near.close()
        far.close()
        out.close()
        ```
        
Keywords: speexdsp,acoustic echo cancellation
Platform: Linux
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: C++
Description-Content-Type: text/markdown
