Skip to content

Commit bf2ef5a

Browse files
committed
feat: teach Python to hear - WebRTC audio processing bindings
Python bindings for WebRTC's audio processing pipeline, bringing noise suppression, echo cancellation, automatic gain control, and voice activity detection to the Python ecosystem via pybind11. Includes vendored WebRTC audio sources, C++ bindings, CI workflow, benchmarks, examples, and a comprehensive test suite.
0 parents  commit bf2ef5a

1,648 files changed

Lines changed: 193710 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pr-and-push.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Pull Request and Push
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
types: [opened, synchronize, reopened, ready_for_review]
7+
push:
8+
branches: [main]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
call-test:
16+
uses: ./.github/workflows/test.yml
17+
permissions:
18+
contents: read
19+
with:
20+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
call-test:
10+
uses: ./.github/workflows/test.yml
11+
permissions:
12+
contents: read
13+
with:
14+
ref: ${{ github.event.release.target_commitish }}
15+
16+
build_wheels:
17+
name: Build wheels on ${{ matrix.os }}
18+
needs: [call-test]
19+
runs-on: ${{ matrix.os }}
20+
permissions:
21+
contents: read
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest, macos-latest, windows-latest]
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
persist-credentials: false
29+
submodules: true
30+
31+
- name: Set up QEMU
32+
if: runner.os == 'Linux'
33+
uses: docker/setup-qemu-action@v4
34+
with:
35+
platforms: arm64
36+
37+
- uses: pypa/cibuildwheel@v2.21
38+
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: wheels-${{ matrix.os }}
42+
path: wheelhouse/*.whl
43+
44+
build_sdist:
45+
name: Build source distribution
46+
needs: [call-test]
47+
runs-on: ubuntu-latest
48+
permissions:
49+
contents: read
50+
steps:
51+
- uses: actions/checkout@v4
52+
with:
53+
persist-credentials: false
54+
submodules: true
55+
56+
- run: pipx run build --sdist
57+
58+
- uses: actions/upload-artifact@v4
59+
with:
60+
name: sdist
61+
path: dist/*.tar.gz
62+
63+
publish:
64+
name: Upload to PyPI
65+
needs: [build_wheels, build_sdist]
66+
runs-on: ubuntu-latest
67+
environment:
68+
name: pypi
69+
url: https://pypi.org/p/pywebrtc-audio
70+
permissions:
71+
id-token: write
72+
steps:
73+
- uses: actions/download-artifact@v4
74+
with:
75+
path: dist
76+
merge-multiple: true
77+
78+
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
test:
12+
name: Test on ${{ matrix.os }} (${{ matrix.arch }})
13+
runs-on: ${{ matrix.os }}
14+
permissions:
15+
contents: read
16+
strategy:
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
arch: x86_64
21+
- os: ubuntu-latest
22+
arch: aarch64
23+
qemu: true
24+
- os: macos-latest
25+
arch: arm64
26+
- os: macos-latest
27+
arch: x86_64
28+
- os: windows-latest
29+
arch: AMD64
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
ref: ${{ inputs.ref }}
34+
persist-credentials: false
35+
submodules: true
36+
37+
- name: Set up QEMU
38+
if: matrix.qemu
39+
uses: docker/setup-qemu-action@v4
40+
with:
41+
platforms: arm64
42+
43+
- uses: pypa/cibuildwheel@v2.21
44+
env:
45+
CIBW_BUILD: "cp312-*"
46+
CIBW_ARCHS: ${{ matrix.arch }}

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Build artifacts
2+
build/
3+
dist/
4+
wheelhouse/
5+
_skbuild/
6+
*.egg-info/
7+
8+
# Python
9+
__pycache__/
10+
*.py[cod]
11+
*.so
12+
*.dylib
13+
*.pyd
14+
15+
# C/C++
16+
*.o
17+
*.a
18+
*.lib
19+
CMakeCache.txt
20+
CMakeFiles/
21+
cmake_install.cmake
22+
Makefile
23+
24+
# Testing
25+
.pytest_cache/
26+
27+
# IDE
28+
.vscode/
29+
.idea/
30+
31+
# OS
32+
.DS_Store
33+
34+
# Script / example output
35+
/*.wav

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(pywebrtc_audio LANGUAGES C CXX)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
7+
8+
add_subdirectory(vendor/webrtc_audio)
9+
10+
find_package(pybind11 CONFIG REQUIRED)
11+
pybind11_add_module(_webrtc_audio bindings/webrtc_audio_bindings.cpp)
12+
target_link_libraries(_webrtc_audio PRIVATE webrtc_audio_static)
13+
target_include_directories(_webrtc_audio PRIVATE vendor/webrtc_audio)
14+
15+
install(TARGETS _webrtc_audio DESTINATION pywebrtc_audio)

CODE_OF_CONDUCT.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Code of Conduct
2+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4+
opensource-codeofconduct@amazon.com with any additional questions or comments.

CONTRIBUTING.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Contributing Guidelines
2+
3+
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4+
documentation, we greatly value feedback and contributions from our community.
5+
6+
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7+
information to effectively respond to your bug report or contribution.
8+
9+
10+
## Reporting Bugs/Feature Requests
11+
12+
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13+
14+
When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15+
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16+
17+
* A reproducible test case or series of steps
18+
* The version of our code being used
19+
* Any modifications you've made relevant to the bug
20+
* Anything unusual about your environment or deployment
21+
22+
23+
## Contributing via Pull Requests
24+
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25+
26+
1. You are working against the latest source on the *main* branch.
27+
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28+
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29+
30+
To send us a pull request, please:
31+
32+
1. Fork the repository.
33+
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34+
3. Ensure local tests pass.
35+
4. Commit to your fork using clear commit messages.
36+
5. Send us a pull request, answering any default questions in the pull request interface.
37+
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38+
39+
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40+
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41+
42+
43+
## Finding contributions to work on
44+
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
45+
46+
47+
## Code of Conduct
48+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50+
opensource-codeofconduct@amazon.com with any additional questions or comments.
51+
52+
53+
## Security issue notifications
54+
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55+
56+
57+
## Licensing
58+
59+
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.

0 commit comments

Comments
 (0)