Skip to content

Hallicopter/go-dtmf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-dtmf, the simplest way to decode DTMF audio in golang.

This library provides two high level API to decode DTMF audio or byte slice. It uses the Goertzel algorithm.

Examples

The example can be run from the examples folder.

go run examples/dtmf_file.go

Docs

dtmf

import "go-dtmf/dtmf"

Usage

func DecodeDTMFFromBytes

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

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.

Credits

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.