GithubHelp home page GithubHelp logo

jcarhuazv / dtmf-decoder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ribt/dtmf-decoder

0.0 0.0 0.0 2.39 MB

Extract phone numbers from an audio recording of the dial tones.

Python 100.00%

dtmf-decoder's Introduction

DTMF decoder

(Sorry for my English, I'm not dumb but French. Feel free to make a PR to correct this README.)

You always dreamt to find the phone number dialled by someone in a video? It's now possible! You have to record the audio of the beeps and this script will extract phone numbers from the dial tones.

Installation

(If you are on Mac or Windows, go to hell.)

$ git clone https://github.com/ribt/dtmf-decoder/
$ cd dtmf-decoder
$ sudo python3 -m pip install -r requirements.txt --upgrade
$ chmod +x dtmf.py
$ sudo cp dtmf.py /usr/local/bin/dtmf

Usage

You have to give a wav file (you can try to convert it with ffmpeg -i audio.mp3 audio.wav for example).

Usage: dtmf [-h] [-v] [-l] [-r] [-d] [-t F] [-i T] file.wav

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  show a complete timeline
  -l, --left     left channel only (if the sound is stereo)
  -r, --right    right channel only (if the sound is stereo)
  -d, --debug    show graphs to debug
  -t F           acceptable frequency error (in hertz, 20 by default)
  -i T           process by T seconds intervals (0.05 by default)

Examples

You can test this script with these examples :

The perfect case

$ dtmf perfect-example.wav
0123456789

As you can see it works perfectly, we have a classical French phone number.

The non-perfect case

$ dtmf not-perfect-example.wav
012374526789

We can guess there is a problem because we have more than ten numbers. So try the verbose output:

$ dtmf -v not-perfect-example.wav
0:00 ...................0
0:01 0..........1111.....
0:02 .....222............
0:03 33........7.......44
0:04 .......5..........2.
0:05 .66666............77
0:06 777.............888.
0:07 ..........99........
0:08 .................

We can guess there are false positives so try to decrease the tolerance:

$ dtmf -v -t 10 not-perfect-example.wav 
0:00 ...................0
0:01 0..........111......
0:02 .....222............
0:03 3..................4
0:04 .......5............
0:05 ..66.6..............
0:06 7...............88..
0:07 ...........9........
0:08 .................

The number 6 must have been split into two so the number is 0123456789.

How it works

This script is quite simple. We split the signal into frames and we analyse them one by one. We calculate a Fast Fourier Transorm to find its constituent frequencies. We find the frequencies with the bigger amplitude and we compare them with the DTMF's (dual-tone multi-frequency) frequencies.

DTMF keypad frequencies from Wikipedia:

array of dial tones' frequencies from Wikipedia

Graph explaining the functioning :

graphs

dtmf-decoder's People

Contributors

clemg avatar ribt avatar

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.