PyS60 DTMF Detector


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.

for this to work with PyS60 1.3.17 I had to install the and 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


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: All the code not given in that entry I wrote myself.

Please email me with any comments about DTMFdetector.

25 Responses to PyS60 DTMF Detector

  1. Nikhil Das says:

    Can u plz mail me the entire folder as zip comprising code,wav file, your obtained results,
    and report if any!!!
    Do u hv C/C++ code for this as I m unfamiliar with python?? if possible mail that 2!!
    Awaiting your mail!!!! Thanks a lot!!!

  2. sachin jain says:

    sir made dtmf based project but i have no idia of dtmf decoder plz tell me work of dtmf decoder\encoder

  3. Charles says:

    Please can you make the wav files available also?

    • etherton says:

      I’m afraid I haven’t worked on this in a long time, but I’m sure if you google “DTMF wav file” you’ll find some wave files that will work.

  4. Bharat Goyal says:

    I have been trying this for a while. Is it necessary to have the audio samples at 8/16 KHz.. I have testing it for a file having an audio sample at 11025 Hz, also I get errors with the variable ‘raw’ –

    line 324, in getDTMFfromWAV
    (sample,) = struct.unpack(“h”, raw)
    error: unpack requires a string argument of length 2

    • etherton says:

      So I honestly don’t understand the math in the Goertzel algorithm well enough to know exactly what you should do, so I’d start by setting self.SAMPLING_RATE to 11025 and then try playing with the self.GOERTZEL_N between 92 and 210 until it works.

      For the error regarding unpack. Do you know what raw contains when it’s passed into struct.unpack()? I suspect you’re using a newer version of python than when I wrote the library, and maybe file.readframes(1) is returning something different.

  5. Vishal says:


    Sorry to post a question on old chain.

    Can I please know, what item corresponds to “GOERTZEL_N” in Goertzel algorithm? Is it normalizedfreq?

    Also, if we want to calculate in “normalizedfreq = freq / SAMPLEFREQUENCY;” for Goertzel algorithm, I assume “freq” is nAvgBytesPerSec and “SAMPLEFREQUENCY” is nSamplesPerSec in FMT chunk wav file. Please correct if I am wrong.

    Using this I am trying to understand what should be the correct value for GOERTZEL_N to be used in your python script.


  6. Hai, iam from india.Iam a plus two student.Now iam learning python.Can you give me a simple dtmf app.If i can controll another s60 via my phone

  7. conatic says:

    I have tried to decode a number with 2 same digits one after another one and the program doesn’t decode the second digit. On this website there is a link to a good dtfm
    detector :

  8. Hai Conatic whr ru frm.I like python.Can you help me.I need a app to controll a phone via phone call.If i pressed 1,2 respectively a app will run.Can you help me to make this

  9. Abilash ov-fb iam on fb pls help me

  10. eltehe says:

    ImportError: No module named chunk

  11. name says:

    Hay. I need a help.i want to controll my phone via another phone.if i pressed 1 in my n73 my another phone can detect that press.can this dtmf is able to do this

  12. name says:

    i nee 1 more can i get bass and trouble in a mp3.i means ineed to make graphical visualisation spectrum

  13. name says:

    helo thanks for your replay i think that you never see what i am writted.iam very happy now.becos your watching the my words. Iam not fluent in english. I know only malayalam,tamil,hindi

  14. name says:

    do you hear about kerala.

  15. abi says:

    how many keys we can detect.i mean if iam using e90.can i detect all key camera,red key,pen

  16. abi says:

    thanks etherton. Great work.very usefull module

Leave a Reply

Your email address will not be published. Required fields are marked *