This library provides two high level API to decode DTMF audio or byte slice. It uses the Goertzel algorithm.
The example can be run from the examples folder.
go run examples/dtmf_file.go
import "go-dtmf/dtmf"
func DecodeDTMFFromBytes(audioBytes []byte, rate float64, wiggleRoom int) (string, error)
DecodeDTMFFromBytes This decodes the audio bytes and saves the value in DTMF.DecodedValue The wiggleRoom value is recommended to be between 5-15. For shorter, sharper, faster DTMF audios, a wiggleRoom of 5 would be good. For longer, more continuous DTMF audios, a higher wiggleRoom will prevent false repeats.
func DecodeDTMFFromFile(filepath string, rate float64, wiggleRoom int) (string, error)
DecodeDTMFFromFile Expects raw audio as the input, gives the decoded DTMF string as output. The wiggleRoom value is recommended to be between 5-15. For shorter, sharper, faster DTMF audios, a wiggleRoom of 5 would be good. For longer, more continuous DTMF audios, a higher wiggleRoom will prevent false repeats.
It was initially built on goertzel by CyCoreSystems, but has been since ported to use a modified version of go-dsp. The underlying principle remains unchanged.