PyS60 DTMF Detector
Download DTMFdetector.py
I made this so I could do DTMF detection with Python on a Nokia Series 60 phone. I made it as quickly as I could, so that’s all it really does. Since this is all it really does it only works for WAV files that were recorded in the format that PyS60 records audio, which is one channel sampled at 8000hz in 16 bits. This is my first attempt at making a general, reusable library for PyS60.
- IMPORTANT:
- for this to work with PyS60 1.3.17 I had to install the wave.py and chunk.py files from my python 2.2 installation onto the phone as libraries.
- Usage example:
- Assume we have a single channel 16 bit, 8000hz file “audioFile.wav” that was recorded on a phone when someone pressed 8,3,3,4,5
from DTMFdetector import DTMFdetector
dtmf = DTMFdetector()
data = dtmf.getDTMFfromWAV("audioFile.wav")print data
OUTPUT:
"83345"
- It’s that simple
- 16khz samples:
- To make the detector work with files that sample at 16khz instead of 8khz make the following changes:
-
self.GOERTZEL_N = 210 self.SAMPLING_RATE = 16000
- License Stuff:
- This code is released to the public for any use. I wish I knew which license that is but I don’t know. I should probably find out. This is code is offered as is with out any warranty. If it breaks and does something bad, don’t sue me. I have tested it to the best of my ability, but I have no doubt that it has numerous faults. The Goertzel algorithm used in this script was shamelessly stolen from this wikipedia entry: http://en.wikipedia.org/wiki/Goertzel_algorithm All the code not given in that entry I wrote myself.
Please email me with any comments about DTMFdetector.