A simple python script for detecting DTMF tones in time domain signals. The best practice for DTMF detection is using Goertzel algorithm to detect only select frequencies. At the time of creation, there is no easily accesible python library that implements it. Consequently, this package uses numpy's efficient FFT implementation instead. The detector function works on smaller chunks of a given signal in time domain and returns the detected DTMF tones. They are detected, when no other frequencies have significant amplitude in the input chunks. Any longer inputs should be split to ~50ms chunks before being used in the detector. Implementation specifics are explained in the code comments.
Input:
indata
: array like object, chunk of signal samples
sample_rate
: sample rate of the discrete signal
Output:
detected
: string or None, detected dtmf tone
from Dtmf import detect_dtmf
detected = detect_dtmf(indata, sample_rate)
A longer signal should be split into shorter ~50 ms windows.
DtmfSignalAnalysis.py
: Plots a real DMTF signal generated by a mobile phone in both time and frequency domain. Prints the most significant frequencies and the detected tone.
DtmfFromAudioInputStream.py
: Live DTMF detection from an input sound device. Intended to be used with a phone connected to the microphon port. Prints detected DTMF signals.
HugoController.py
: Expands on the last example, by triggering keyboard inputs for the 1997 Hugo 4 game for PC. This is intended to recreate how the game was originally played on the early 90's TV game-show. A member of the audience watching at home was selected to play the game on live TV, by inputting the commands through their telephone set.
The resources directory contains a recording of 12 standard DTMF signals generated by Huawei P30.