Coder Social home page Coder Social logo

bert2 / dtmfdetection Goto Github PK

View Code? Open in Web Editor NEW
42.0 4.0 19.0 6.46 MB

C# implementation of the Goertzel algorithm for DTMF tone (a.k.a. Touch-Tone) detection and localization in audio data. Includes wrappers and extensions for NAudio.

License: MIT License

C# 95.16% PowerShell 4.84%
dtmf dtmf-detector dtmf-decoder dtmfgenerator goertzel-algorithm naudio touch-tone

dtmfdetection's People

Contributors

bert2 avatar dependabot[bot] 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dtmfdetection's Issues

LiveAudioDtmfAnalyzer seems not working

I'm unable to run both the samples
How to detect DTMF tones through mic in, but with each audio channel analyzed separately and
How to detect DTMF tones in the current audio output
and i suspect there is something not working in LiveAudioDtmfAnalyzer

I am testing playing DTMF sound from cell phone app and the site http://onlinetonegenerator.com/dtmf.html

I am placing cell phone in front of my external microphone, as well of the speaker of my PC if I use the generator online.

Please consider that:

  • If I just use N-Audio, I am able to obtain correctly data from WaveInEvent micIn, and execute, for example, the FFT - so I have no doubt that my microphone is working correctly with N-Audio acquisition.

  • When testing scenario How to detect DTMF tones in the current audio output I have activated the listening of the microphone input in Windows audio properties.

  • If i use the example named How to print all DTMF tones in an MP3 file, but with each audio channel analyzed separately: it works well.

I hope this can help you to improve your library!

Thanks and regards,
Francesco

Expected Behavior

I'm expecting DtmfToneStarted and DtmfToneStopped events are raised.

Current Behavior

DtmfToneStarted and DtmfToneStopped events are never raised.

How to ensure the latest NAudio version is in use?

Hi @bert2 ,

I've been trying to upgrade NAudio package to the latest release (2.1.0) using dotnet add package NAudio --version 2.1.0 in the below three csproj:

unit.csproj
integration.csproj
dtmf-detector.csproj
DtmfDetection.NAudio.csproj

Is that sufficient to claim that DtmfDetection.NAudio is using the latest NAudio version ?

Is it possible to change the detection frequency?

Hi @bert2

Is it possible to change the detection frequency, or process by T seconds intervals ?

By default, the DTMF duration is 40ms. But sometimes it can be 60, 70, or even 80ms.

So the precision of the result depends on the number of detection per seconds.

Is there a way to modify it with DtmfDetection, or is it fixed?

Can the project be built on Linux?

Hello @bert2

First of all, thanks for this great project.

I'm trying to compile it for Linux, and even though I installed dotnet, powershell, and all, I keep getting the following error:

./build.ps1
Preparing to run build script...
Running build script...
**Error: Failed to install addin 'Cake.Git'.**

And with verbose, I get that :

Installing addins...
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/cake.codecov/index.json
The addin Cake.Codecov will reference Cake.Codecov.dll.
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/cake.git/index.json
Assemblies not found for tfm .NETFramework,Version=v4.6.1 and rid [NULL].
No assemblies found after running content resolver.
Error: Cake.Core.CakeException: Failed to install addin 'Cake.Git'.
  at Cake.Core.Scripting.ScriptProcessor.InstallAddins (System.Collections.Generic.IReadOnlyCollection`1[T] addins, Cake.Core.IO.DirectoryPath installPath) [0x000c0] in <040622b6758f456b89fd2a5b24e3e64c>:0
  at Cake.Core.Scripting.ScriptRunner.Run (Cake.Core.Scripting.IScriptHost host, Cake.Core.IO.FilePath scriptPath) [0x0013b] in <040622b6758f456b89fd2a5b24e3e64c>:0
  at Cake.Features.Building.BuildFeature.RunCore (Spectre.Console.Cli.IRemainingArguments arguments, Cake.Features.Building.BuildFeatureSettings settings) [0x0010d] in <21a7d41a88904b88a0986b85ed354c53>:0
  at Cake.Features.Building.BuildFeature.Run (Spectre.Console.Cli.IRemainingArguments arguments, Cake.Features.Building.BuildFeatureSettings settings) [0x00012] in <21a7d41a88904b88a0986b85ed354c53>:0
  at Cake.Commands.DefaultCommand.Execute (Spectre.Console.Cli.CommandContext context, Cake.Commands.DefaultCommandSettings settings) [0x000d0] in <21a7d41a88904b88a0986b85ed354c53>:0

My dotnet info :

dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.300
 Commit:    8473146e7d

Runtime Environment:
 OS Name:     debian
 OS Version:  11
 OS Platform: Linux
 RID:         debian.11-arm64
 Base Path:   /home/xxxxxxxx/.dotnet/sdk/6.0.300/

Host (useful for support):
  Version: 6.0.5
  Commit:  70ae3df4a6

.NET SDKs installed:
  6.0.300 [/home/xxxxx/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.5 [/home/xxxxx/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.5 [/home/xxxxx/.dotnet/shared/Microsoft.NETCore.App]

Do you know what is causing the issue? I tried to pin Cake addin to other versions but the issue remains.

Thanks for your help in advance.

DTMF detector fails for 48KHz audio

DTMF detector is not working correctly with audio files that have a sample a rate of 48 KHz.

Expected Behavior

  • Detector should work with 48 KHz audio.

Current Behavior

  • When 48 KHz audio is fed to the detector it will miss actual DTMF tones and find false positives.

Possible Cause

  • NAudio's WdlResamplingSampleProvider seems to be unable to suppress aliasing effects when downsampling from 48 KHz to 8 KHz

Steps to Reproduce

  1. Run integration test AudioFileTests.ShouldDownsample48KHzCorrectly()

Possible Solution

  • Try another of NAudio's resamplers
  • Low-pass filter the audio data with cut-off at 8 KHz before downsampling

System.Threading.ThreadAbortException

Exception thrown: 'System.Threading.ThreadAbortException' in mscorlib.dll

I use VS2017, it's not working after successfully built. Showing error on when I pressing "o" or "m".

image

FSK CallerID decoder

Hi, any plans to implement an FSK CallerID decoder? Thanks in advance. Best, Angelo

Identify off-hook phone

Hello, I use the dll some time ago. I implemented a timer in my code to identify the conversation. When this timer reaches 15 seconds of silence, I close the recording of the conversation.
But often the voice of who is on the other side of the line is very low, which ends up in the middle of the conversation breaking the recording.
In short, is there a way to identify if the phone is off the hook, via audio, or some other dll?
Thank you.

How to implement microphone volume

Hello everyone, I have been using the class to identify flames but I would like to increment my software with volumes and vu meter. Anyone have any practical examples in C # or VB.NET so I can test?

thank you.

Is it possible to use a named pipe (fifo) as input of NAudio?

Hi, @bert2

I'm working on a requirement where I'm transcoding some live audio stream from M1-L2/AAC to PCM .wav, on the fly.

Then, I need to feed NAudio with that live .wav audio stream, because it doesn't come from any audio device (mic/speaker) but from the network.

I'm wondering if it is possible to use a named pipe (fifo) as input ?

I'm aware this may have its own challenge since ultimately this named pipe is a kinda file, so NAudio may not understand what's going on, therefore my question.

If the above is not possible, is there any other alternatives?

Repeating DTMF tones are not detected correctly when played too fast

When a DTMF tone is repeatedly played in short intervals, the DTMF detector will sometimes fail to tell them apart and report them as a single DTMF tone occurence instead.

Repro Steps

Repro Steps (Alternative)

Note

This could be an issue with the test data. The tones might be played faster than the typical Mark/Space of 40/40, which the detector assumes as minimum.

WaveFileReaderExtensions.cs suggestion

To support detect DTMF from all NAudio supported file types, change "WaveFileReaderExtensions.cs" like this:

namespace DtmfDetection.NAudio
{
    using System.Collections.Generic;

    using global::NAudio.Wave;

    public static class WaveFileReaderExtensions
    {
        public static IEnumerable<DtmfOccurence> DtmfTones(this WaveStream waveFile)
        {
            var dtmfAudio = new DtmfAudio(new StaticSampleSource(waveFile));

            while (dtmfAudio.WaitForDtmfTone() != DtmfTone.None)
            {
                var start = waveFile.CurrentTime;
                dtmfAudio.WaitForEndOfLastDtmfTone();
                var duration = waveFile.CurrentTime - start;

                yield return new DtmfOccurence(dtmfAudio.LastDtmfTone, start, duration);
            }
        }


    }
}

Thanks.

Consuming too much processor.

I implemented the dll in my project. but only it consumes 20% of my processor.
Is there any way to improve this?
Thank you.

Incorrect keys at start of sequence

I'm using "pure" PCM 16 bit 8000Hz 100ms WAV files as a source.

If I transmit a "long" sequence of DTMF codes
e.g.
1234567890#*
The last digits are detected correctly (with durations of around 6 to 8 milliseconds)
But I usually get incorrect and/or extra digits at the start (with durations of 4 to 5 milliseconds)

For the sequence above for instance I just got
One key 0.0050005 (channel 0)
One key 0.0050005 (channel 0)
Two key 0.0040004 (channel 0)
One key 0.0050005 (channel 0)
Two key 0.0060006 (channel 0)
Three key 0.0070007 (channel 0)
Four key 0.0070007 (channel 0)
Five key 0.0070007 (channel 0)
Six key 0.0070007 (channel 0)
Seven key 0.0070007 (channel 0)
Eight key 0.0070007 (channel 0)
Nine key 0.0080008 (channel 0)
Zero key 0.0080008 (channel 0)
Star key 0.0080008 (channel 0)
Hash key 0.0080008 (channel 0)

Reversing the order (#0987654321), I first got a correct set, then got
9
87654321

Now admittedly, this is going over UDP out to a SIP server and back again, so I guess it's possible that I'm getting packet loss or out of order arrival, but is there any way to tell that? Or to adjust the minimum detection interval?

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.