C# bindings for SpeexDSP echo cancellation and preprocessing with bundled native runtime libraries.
The NuGet package id is tryAGI.SpeexDspSharp. The public namespace remains
SpeexDspSharp.
dotnet add package tryAGI.SpeexDspSharpusing SpeexDspSharp;
var sampleRate = 16000;
var frameSize = sampleRate / 50; // 20 ms
var filterLength = sampleRate / 5; // 200 ms
using var echo = new SpeexEchoState(sampleRate, frameSize, filterLength);
var playback = new short[frameSize];
var microphone = new short[frameSize];
var cleaned = new short[frameSize];
echo.RegisterPlayback(playback);
echo.Capture(microphone, cleaned);SpeexEchoState wraps SpeexDSP's streaming API. Playback and capture frames must
be exactly FrameSize 16-bit mono samples.
The package contains native runtime assets under NuGet runtimes/<rid>/native/:
runtimes/win-x64/native/speexdsp.dllruntimes/osx-x64/native/libspeexdsp.dylibruntimes/osx-arm64/native/libspeexdsp.dylibruntimes/linux-x64/native/libspeexdsp.soruntimes/linux-arm64/native/libspeexdsp.so
The native binaries are committed in natives/ so consumers do not need a
system SpeexDSP installation.
Run the refresh script from the repository root:
natives/refresh.shThe script stages Linux binaries from Debian packages, Windows x64 from MSYS2, and macOS from Homebrew.
dotnet build SpeexDspSharp.slnx
dotnet test src/tests/SpeexDspSharp.Tests/SpeexDspSharp.Tests.csproj
dotnet pack src/libs/SpeexDspSharp/SpeexDspSharp.csproj -c ReleaseSpeexDspSharp is licensed under MIT. Bundled SpeexDSP native binaries retain the
upstream BSD license; see THIRD-PARTY-NOTICES.md.