https://github.com/hallicopter/go-dtmf
Decode DTMF audio in go.
https://github.com/hallicopter/go-dtmf
dtmf dtmf-decoder
Last synced: 2 months ago
JSON representation
Decode DTMF audio in go.
- Host: GitHub
- URL: https://github.com/hallicopter/go-dtmf
- Owner: Hallicopter
- Created: 2021-09-03T08:03:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-03T07:01:09.000Z (about 2 years ago)
- Last Synced: 2024-06-21T16:51:30.545Z (almost 2 years ago)
- Topics: dtmf, dtmf-decoder
- Language: Go
- Homepage:
- Size: 297 KB
- Stars: 8
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# go-dtmf, the simplest way to decode DTMF audio in golang.
This library provides two high level API to decode [DTMF](https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling) 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
```go
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
```go
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](https://github.com/CyCoreSystems/goertzel) by CyCoreSystems, but has been since ported to use a modified version of [go-dsp](https://github.com/samuel/go-dsp).
The underlying principle remains unchanged.