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](https://arxiv.org/abs/2106.04129).
> 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
```shell
sudo apt install libspeexdsp-dev
sudo apt install swig
python setup.py install
```
## Get started
```python
"""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](examples/pic.jpg)
Raw data
{
"_id": null,
"home_page": "https://github.com/TeaPoly/speexdsp-ns-python",
"name": "speexdsp-ns",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "speexdsp_ns,acoustic noise suppression",
"author": "Lucky Wong",
"author_email": "",
"download_url": "",
"platform": "Linux",
"description": "Python bindings of speexdsp noise suppression library\n===================\n\nModified from https://github.com/xiongyihui/speexdsp-python\n\nYou can use it in Noise reduction model training as said in [Personalized PercepNet: Real-time, Low-complexity Target Voice Separation and Enhancement](https://arxiv.org/abs/2106.04129).\n> Use a VAD and lightweight denoiser (SpeexDSP1) to eliminate the stationary noise before using this data for training.\n\n## Requirements\n+ swig\n+ compile toolchain\n+ python\n+ libspeexdsp-dev\n\n## Build\n```shell\nsudo apt install libspeexdsp-dev\nsudo apt install swig\npython setup.py install\n```\n\n## Get started\n\n```python\n\"\"\"Acoustic Noise Suppression for wav files.\"\"\"\n\nimport wave\nimport sys\nfrom speexdsp_ns import NoiseSuppression\n\n\nif len(sys.argv) < 3:\n print('Usage: {} near.wav out.wav'.format(sys.argv[0]))\n sys.exit(1)\n\n\nframe_size = 256\n\nnear = wave.open(sys.argv[1], 'rb')\n\nif near.getnchannels() > 1:\n print('Only support mono channel')\n sys.exit(2)\n\nout = wave.open(sys.argv[2], 'wb')\nout.setnchannels(near.getnchannels())\nout.setsampwidth(near.getsampwidth())\nout.setframerate(near.getframerate())\n\n\nprint('near - rate: {}, channels: {}, length: {}'.format(\n near.getframerate(),\n near.getnchannels(),\n near.getnframes() / near.getframerate()))\n\nnoise_suppression = NoiseSuppression.create(frame_size, near.getframerate())\n\nin_data_len = frame_size\nin_data_bytes = frame_size * 2\n\nwhile True:\n in_data = near.readframes(in_data_len)\n if len(in_data) != in_data_bytes:\n break\n\n in_data = noise_suppression.process(in_data)\n\n out.writeframes(in_data)\n\nnear.close()\nout.close()\n```\n\nor\n\n```python examples/main.py in.wav out.wav```\n\nNoise suppression as show in figure below:\n\n![image](examples/pic.jpg)\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Python bindings of speexdsp noise suppression library",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/TeaPoly/speexdsp-ns-python"
},
"split_keywords": [
"speexdsp_ns",
"acoustic noise suppression"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "92d932383636d57848ab28151657e14f1dc4d437585a3bea90a613bc6af601df",
"md5": "607e73df3850acc61753359bae2c7519",
"sha256": "f79b253d44772c40bd2dd3a953d65fa8baf3509a8b468d14cf9e469c7a59bbf9"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp310-cp310-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "607e73df3850acc61753359bae2c7519",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 155527,
"upload_time": "2023-08-07T20:34:46",
"upload_time_iso_8601": "2023-08-07T20:34:46.624438Z",
"url": "https://files.pythonhosted.org/packages/92/d9/32383636d57848ab28151657e14f1dc4d437585a3bea90a613bc6af601df/speexdsp_ns-0.1.2-cp310-cp310-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "60325db7f15f3fb43160cafd9dd9f46ed1047e9d4fb509f13c0079a42a4f7ca3",
"md5": "c358db37acd3f621e030c6e67737ea37",
"sha256": "f3598bd36312335fe2178dc4734a38e82a322fd9c60ea28577ccec9850b8719c"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "c358db37acd3f621e030c6e67737ea37",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 158630,
"upload_time": "2023-08-07T20:34:58",
"upload_time_iso_8601": "2023-08-07T20:34:58.134088Z",
"url": "https://files.pythonhosted.org/packages/60/32/5db7f15f3fb43160cafd9dd9f46ed1047e9d4fb509f13c0079a42a4f7ca3/speexdsp_ns-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6e16ab9442ab375407d1a6130fd1a55686eef24cbeec6223f7b5bd358b68c776",
"md5": "a383e6ac81830882397505c44220900a",
"sha256": "a8f47dd7996b7fceee36f983118500a42963541c0701ab16543ad35dc7a351db"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp311-cp311-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "a383e6ac81830882397505c44220900a",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 156792,
"upload_time": "2023-08-07T20:34:47",
"upload_time_iso_8601": "2023-08-07T20:34:47.795362Z",
"url": "https://files.pythonhosted.org/packages/6e/16/ab9442ab375407d1a6130fd1a55686eef24cbeec6223f7b5bd358b68c776/speexdsp_ns-0.1.2-cp311-cp311-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "39cbb5c16a514950908d2d9201580946973a84d77ea887eb48fdabdc97f13d6d",
"md5": "d58ebe2df5d3a0ae6265001886ef584a",
"sha256": "986ed698264eab2e9c775382739fd7a6b6800b589594b037062f53928b87ea3f"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "d58ebe2df5d3a0ae6265001886ef584a",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 159862,
"upload_time": "2023-08-07T20:35:01",
"upload_time_iso_8601": "2023-08-07T20:35:01.411715Z",
"url": "https://files.pythonhosted.org/packages/39/cb/b5c16a514950908d2d9201580946973a84d77ea887eb48fdabdc97f13d6d/speexdsp_ns-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a07e1b7f7f021736c671b18d69f6f561d5556fd3a5369c94d9c458b4a8fb2e13",
"md5": "f355d0589bb5b26164d74f60711838c0",
"sha256": "09cf0a8f9530fca1f203f53808b074d247b9083df323199bd9d150f70af08338"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp312-cp312-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "f355d0589bb5b26164d74f60711838c0",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": null,
"size": 158227,
"upload_time": "2023-08-07T20:34:52",
"upload_time_iso_8601": "2023-08-07T20:34:52.144189Z",
"url": "https://files.pythonhosted.org/packages/a0/7e/1b7f7f021736c671b18d69f6f561d5556fd3a5369c94d9c458b4a8fb2e13/speexdsp_ns-0.1.2-cp312-cp312-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7b14d9fd843472f82853643c4ae09835c76bfb19ce7e712586cfc1318030503f",
"md5": "7dfcdd5bb33fcbd44fd357fa6f79df8b",
"sha256": "c2c73c2f132212fecfff52a689594f925453ff521fec336411149256aedcd819"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "7dfcdd5bb33fcbd44fd357fa6f79df8b",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": null,
"size": 161569,
"upload_time": "2023-08-07T20:34:59",
"upload_time_iso_8601": "2023-08-07T20:34:59.781028Z",
"url": "https://files.pythonhosted.org/packages/7b/14/d9fd843472f82853643c4ae09835c76bfb19ce7e712586cfc1318030503f/speexdsp_ns-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f73126cfc9ca4a3483ef1a1deb9ebe44c0871f6deeebe7cf53a2d3aee2671e05",
"md5": "e9ff7d7c70c9a8743aee611efc634845",
"sha256": "60702b11a5e250fbd554bf48a932c34d700ac1952190503c8420019aa054a707"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp37-cp37m-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "e9ff7d7c70c9a8743aee611efc634845",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 154096,
"upload_time": "2023-08-07T20:34:50",
"upload_time_iso_8601": "2023-08-07T20:34:50.627908Z",
"url": "https://files.pythonhosted.org/packages/f7/31/26cfc9ca4a3483ef1a1deb9ebe44c0871f6deeebe7cf53a2d3aee2671e05/speexdsp_ns-0.1.2-cp37-cp37m-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "247a89c6f400b92903ef8f28f6e078a1b5f9deb7ad64b0903d7dacff73c7b829",
"md5": "3afcf0ca97d104622bc6bacd509bded1",
"sha256": "68d14e0457f419b7d663c3316d46116b50b85fc97e3340ab2f15a2131b195b86"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp37-cp37m-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "3afcf0ca97d104622bc6bacd509bded1",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 157375,
"upload_time": "2023-08-07T20:34:54",
"upload_time_iso_8601": "2023-08-07T20:34:54.747850Z",
"url": "https://files.pythonhosted.org/packages/24/7a/89c6f400b92903ef8f28f6e078a1b5f9deb7ad64b0903d7dacff73c7b829/speexdsp_ns-0.1.2-cp37-cp37m-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2a18456448055a88ef177f7b2c9022fafabe05bc0e4179857efe31487c8619ca",
"md5": "18d9290519c2d007c0e7e96263db6624",
"sha256": "75b0db25b7bf91dc77dafb614a05cff7518d5a23f94a3245ca3200636db1d873"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp38-cp38-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "18d9290519c2d007c0e7e96263db6624",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": null,
"size": 156058,
"upload_time": "2023-08-07T20:34:49",
"upload_time_iso_8601": "2023-08-07T20:34:49.579611Z",
"url": "https://files.pythonhosted.org/packages/2a/18/456448055a88ef177f7b2c9022fafabe05bc0e4179857efe31487c8619ca/speexdsp_ns-0.1.2-cp38-cp38-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "93da5ed5ffc2b7fcc768957be7c1d899dddc3067990d18d5f0dd744742e95d59",
"md5": "6ecd224a61c075f57918b5e06a467b20",
"sha256": "8bb7c3d26ac921cb4aa628b2b9345a4ade55ce54fd7980bd514355ff8708fab6"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp38-cp38-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "6ecd224a61c075f57918b5e06a467b20",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": null,
"size": 159191,
"upload_time": "2023-08-07T20:34:53",
"upload_time_iso_8601": "2023-08-07T20:34:53.665991Z",
"url": "https://files.pythonhosted.org/packages/93/da/5ed5ffc2b7fcc768957be7c1d899dddc3067990d18d5f0dd744742e95d59/speexdsp_ns-0.1.2-cp38-cp38-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "56cb6623e3f60ab91253479ece529ed6a427a29b64e2c1ebfb61ebfbdd04968f",
"md5": "ec5e35e4632e26eb89c06c753f841d87",
"sha256": "c2b93df63a9f230f110101d08207f338bb93de3022d94fccd49ad7de768490c1"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp39-cp39-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "ec5e35e4632e26eb89c06c753f841d87",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": null,
"size": 155422,
"upload_time": "2023-08-07T20:34:44",
"upload_time_iso_8601": "2023-08-07T20:34:44.859205Z",
"url": "https://files.pythonhosted.org/packages/56/cb/6623e3f60ab91253479ece529ed6a427a29b64e2c1ebfb61ebfbdd04968f/speexdsp_ns-0.1.2-cp39-cp39-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "29a6f3149a64305da8f13f77edf22ddcf03151e0b7f1089d63bf43eff0b15d09",
"md5": "da546ffd077bab0ee370f4596d731c45",
"sha256": "754fbdf30d219a84714fc77406e8ea6a9b5528641493494dddd2554a8dbb7f88"
},
"downloads": -1,
"filename": "speexdsp_ns-0.1.2-cp39-cp39-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "da546ffd077bab0ee370f4596d731c45",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": null,
"size": 158480,
"upload_time": "2023-08-07T20:34:56",
"upload_time_iso_8601": "2023-08-07T20:34:56.333172Z",
"url": "https://files.pythonhosted.org/packages/29/a6/f3149a64305da8f13f77edf22ddcf03151e0b7f1089d63bf43eff0b15d09/speexdsp_ns-0.1.2-cp39-cp39-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-07 20:34:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TeaPoly",
"github_project": "speexdsp-ns-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "speexdsp-ns"
}