ladenedge / webrtcvadsharp Goto Github PK
View Code? Open in Web Editor NEW.NET Standard interface for the WebRTC voice activity detection (VAD) component.
License: Other
.NET Standard interface for the WebRTC voice activity detection (VAD) component.
License: Other
Just getting this sort of thing:
Valid values are []
When i use NAudio to record sound, HasSpeech always true.
here is my code :
_waveIn = new WaveInEvent();
_waveIn.WaveFormat = new WaveFormat(16000, 1);
_waveIn.StartRecording();
_waveIn.DataAvailable += (s, a) =>
{
var now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
var hasSpeech = HasSpeech(_vad, a.Buffer, a.BytesRecorded);
....
};
and HasSpeechMethod
public bool HasSpeech(WebRtcVad vad, byte[] buffer, int length, int startIndex = 0)
{
var size = (int)vad.SampleRate / 1000 * 2 * (int)vad.FrameLength;
if (length < size) return false;
var array = new ReadOnlySpan<byte>(buffer, startIndex, length);
for (int postion = 0; postion < (length - size); postion += size)
{
if (vad.HasSpeech(array.Slice(postion, size).ToArray()))
{
Debug.Log("Has speech !");
return true;
}
}
return false;
}
Here is vad initialize code:
_vad = new WebRtcVad();
_vad.FrameLength = FrameLength.Is30ms;
_vad.SampleRate = SampleRate.Is16kHz;
_vad.OperatingMode = OperatingMode.VeryAggressive;
Hi,
I`m writing a voice controller for my smart home and I would like to implement WebRTC-VAD for better voice detection... the room devices are running under linux. Could you provide and linux-arm-version of WebRtcVad.dll?
Thanks you very much
Carl
I am using Visual Studio 2019 to detect speech in audio. I am using the NuGet package version 1.3.0 and when I try to create new WebRtcVad() I get this message: "System.DllNotFoundException: 'Unable to load DLL 'WebRtcVad.dll' or a dependency. [...]"
There are 3 modes of sens detection located here:
WebRtcVadSharp/WebRtcVad/webrtc/common_audio/vad/vad_core.c
Anyway to add more. Using this code for VOX within a flight simulator and it is still to sensitive.
Submitted by Jason Carlson:
Managed Debugging Assistant 'PInvokeStackImbalance' : 'A call to PInvoke function 'WebRtcVadSharp!WebRtcVadSharp.WebRtc.WebRtcDll+NativeMethods::Vad_Process' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature.
We have a problem when a service is published as portable, the WebRtcVad files are not copied to the corresponding runtime folder. The same can happen if the microservice is published for a specific runtime identifier, such as win-x64.
At the moment as a workaround we have added the following code that copies the files after publishing the service.
<Project>
<!-- TODO: This is a workaround to copy the WebRtcVad files to the runtime folder when the service is published.
Remove this code when the WebRtcVadSharp package implements this. -->
<Target Name="PostPublishCopyWebRtcVadFiles" AfterTargets="AfterPublish">
<Warning Text="This project's platform is set to '$(PlatformTarget)', but it requires a native DLL (WebRtcVad.dll). Defaulting to 'x64' binaries. Explicitly choose a platform in the project's Build properties to remove this warning."
Condition="'$(PlatformTarget)' != 'x86' And '$(PlatformTarget)' != 'x64'" />
<PropertyGroup>
<WebRtcPlatformTarget>$(PlatformTarget)</WebRtcPlatformTarget>
<WebRtcPlatformTarget Condition="'$(PlatformTarget)' != 'x86' And '$(PlatformTarget)' != 'x64'">x64</WebRtcPlatformTarget>
</PropertyGroup>
<PropertyGroup>
<IsLinux Condition="Exists ('/proc') and Exists ('/etc/')">true</IsLinux>
<IsOSX Condition="Exists('/Library/Frameworks') and Exists ('/etc')">true</IsOSX>
</PropertyGroup>
<PropertyGroup>
<RuntimeFolder>win-$(WebRtcPlatformTarget)</RuntimeFolder>
<RuntimeFolder Condition="'$(IsLinux)' == 'true'">linux-$(WebRtcPlatformTarget)</RuntimeFolder>
<RuntimeFolder Condition="'$(IsOSX)' == 'true'">osx-$(WebRtcPlatformTarget)</RuntimeFolder>
</PropertyGroup>
<PropertyGroup>
<WebRtcVadFilesOutputPath>$(PublishDir)runtimes\$(RuntimeFolder)\native\</WebRtcVadFilesOutputPath>
</PropertyGroup>
<Message Text="WebRtcVadSharp Post Publish Message" Importance="high"/>
<Message Text="PlatformTarget: $(WebRtcPlatformTarget)" Importance="high"/>
<Message Text="OS: $(OS)" Importance="high"/>
<Message Text="IsLinux: $(IsLinux)" Importance="high"/>
<Message Text="IsOSX: $(IsOSX)" Importance="high"/>
<Message Text="WebRtcVadFilesOutputPath: $(WebRtcVadFilesOutputPath)" Importance="high"/>
<ItemGroup>
<WebRtcVadFiles Include="$(MSBuildThisFileDirectory)**\WebRtcVad.*" />
</ItemGroup>
<Copy SourceFiles="@(WebRtcVadFiles)" DestinationFolder="$(WebRtcVadFilesOutputPath)" />
</Target>
</Project>
One question, the unmanaged x86 and x64 dlls included in the WebRtcVadSharp NuGet package, do they work for any operating system or are they just for Windows?
Thank you in advance
Hello,
I've tried everything that I can think of. I have a very simple implementation here. Really hoping to get some advice. This is going to be a life saver library for my project.
I'm passing in a 16khz, mono channel wav file, codec used was pcm_s16le.
I'm on version 1.3.1, testing on Windows 10 Build 19042
using var vad = new WebRtcVad()
{
OperatingMode = OperatingMode.Aggressive,
FrameLength = FrameLength.Is20ms,
SampleRate = SampleRate.Is16kHz,
};
// I tried with * 1 instead of * 2 here as well, since the wav I'm using is mono channel
var frameSize = (int)vad.SampleRate / 1000 * 2 * (int)vad.FrameLength;
var audioBytes = await File.ReadAllBytesAsync("birds.wav");
for (var i = 0; i < audioBytes.Length - frameSize; i += frameSize)
{
var hasSpeech = vad.HasSpeech(audioBytes.Skip(i).Take(frameSize).ToArray());
if (hasSpeech)
{
// inspecting with breakpoint here, always hits on first pass, when there is no speech.
break;
}
}
Hello, I am using webrtcvadsharp inside Unity, Ive imported that using NuGet.
full log:
DllNotFoundException: webrtcvad assembly: type: member:(null)
WebRtcVadSharp.WebRtc.WebRtcDll.Create () (at :0)
WebRtcVadSharp.WebRtcVad..ctor (WebRtcVadSharp.WebRtc.IWebRtcDll library) (at :0)
Rethrow as DllNotFoundException: Unable to load DLL 'WebRtcVad.dll' or a dependency. Be sure it exists in '/Users/andrescapinlli/Documents/Baires Dev/ObvioHealth/ObvioSpeech/obviospeech' or elsewhere in the DLL search path.
WebRtcVadSharp.WebRtcVad..ctor (WebRtcVadSharp.WebRtc.IWebRtcDll library) (at :0)
WebRtcVadSharp.WebRtcVad..ctor () (at :0)
MicrophoneController.DoesFrameContainSpeech (System.Byte[] audioFrame) (at Assets/Scripts/Recorder/MicrophoneController.cs:56)
MicrophoneController.Update () (at Assets/Scripts/Recorder/MicrophoneController.cs:51)
So basically my code is not finding the .dll. Does someone have any idea how to solve that?
I`ve already tried to change the path to the root of my project, but it also does not work.
On x86 builds, the C# DLL is looking for an entry point that is not available in the C DLL.
System.EntryPointNotFoundException
HResult=0x80131523
Message=Unable to find an entry point named 'Vad_Process' in DLL 'WebRtcVad.dll'.
Source=WebRtcVadSharp
StackTrace:
at WebRtcVadSharp.WebRtc.WebRtcDll.NativeMethods.Vad_Process(IntPtr handle, Int32 fs, Int16[] audio_frame, Int64 frame_length)
at WebRtcVadSharp.WebRtc.WebRtcDll.Process(IntPtr handle, Int32 fs, Int16[] audio_frame, Int64 frame_length)
at WebRtcVadSharp.WebRtcVad.HasSpeech(Int16[] audioFrame, SampleRate sampleRate, FrameLength frameLength)
at WebRtcVadSharp.WebRtcVad.HasSpeech(Int16[] audioFrame)
at ConsoleApp1.Program.Main(String[] _) in C:\Users\laden\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 12
According to Dependency Walker, the names are mangled with an unexpected calling convention:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.