Giter VIP home page Giter VIP logo

webrtcvadsharp's People

Contributors

ladenedge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webrtcvadsharp's Issues

WaveInEvent HasSpeech is always true

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;

Can you provide other versions of WebRtcVad.dll?

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

Unable to find WebRtcVad.dll

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. [...]"

A PInvoke function has unbalanced the stack

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.

WebRtcVad files are not copied after publishing service

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

HasSpeech is always true

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;
    }
}

DllNotFoundException

Hello, I am using webrtcvadsharp inside Unity, Ive imported that using NuGet.

Screenshot 2023-01-20 at 16 03 39

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.

Unable to find an entry point named 'Vad_Process' in DLL 'WebRtcVad.dll'

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:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.