Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filename arg to decoder #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion dtmf-decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@
The wave file is split into bins and each bin is analyzed
for all the DTMF frequencies. The method run() will return a numeric
representation of the DTMF tone.

USAGE:
python dtmf-decoder.py filename

Will decode and print the dtmf tones found in the wav file "filename"

Example:
python dtmf-decoder.py dtmf.wav

'''
import wave
import struct
import math
import sys

class pygoertzel_dtmf:
def __init__(self, samplerate):
self.samplerate = samplerate
Expand Down Expand Up @@ -93,7 +104,7 @@ def run(self, sample):
return self.__get_number(freqs)
if __name__ == '__main__':
# load wav file
wav = wave.open('/home/michael/Downloads/dtmf.wav', 'r')
wav = wave.open(sys.argv[1], 'r')
(nchannels, sampwidth, framerate, nframes, comptype, compname) = wav.getparams()
frames = wav.readframes(nframes * nchannels)
# convert wave file to array of integers
Expand Down