Skip to main content

Python bindings of speexdsp noise suppression library

Modified from https://github.com/xiongyihui/speexdsp-python

You can use it in Noise reduction model training as said in Personalized PercepNet: Real-time, Low-complexity Target Voice Separation and Enhancement.

Use a VAD and lightweight denoiser (SpeexDSP1) to eliminate the stationary noise before using this data for training.

Requirements

  • swig
  • compile toolchain
  • python
  • libspeexdsp-dev

Build

sudo apt install libspeexdsp-dev
sudo apt install swig
python setup.py install

Get started

"""Acoustic Noise Suppression for wav files."""

import wave
import sys
from speexdsp_ns import NoiseSuppression


if len(sys.argv) < 3:
    print('Usage: {} near.wav out.wav'.format(sys.argv[0]))
    sys.exit(1)


frame_size = 256

near = wave.open(sys.argv[1], 'rb')

if near.getnchannels() > 1:
    print('Only support mono channel')
    sys.exit(2)

out = wave.open(sys.argv[2], '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()))

noise_suppression = NoiseSuppression.create(frame_size, near.getframerate())

in_data_len = frame_size
in_data_bytes = frame_size * 2

while True:
    in_data = near.readframes(in_data_len)
    if len(in_data) != in_data_bytes:
        break

    in_data = noise_suppression.process(in_data)

    out.writeframes(in_data)

near.close()
out.close()

or

python examples/main.py in.wav out.wav

Noise suppression as show in figure below:

image

Metadata

Release files for platypush-speexdsp-ns 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for platypush-speexdsp-ns 0.1.2
File Size Uploaded Provenance Actions
platypush_speexdsp_ns-0.1.2.tar.gz 8.6 kB Without provenance Details for platypush_speexdsp_ns-0.1.2.tar.gz

Release files / platypush_speexdsp_ns-0.1.2.tar.gz

Download URL platypush_speexdsp_ns-0.1.2.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
aacb6da72051135b00ec4ea3cffd508ba7818a950e07b1a72f565146bb8f47a8
BLAKE2b-256 checksum
How to use checksums
f2d3a72abf7c003ba8f23337dc19ea7c90ef65d9258221e6b89ea137d1a467fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for platypush-speexdsp-ns 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page