A node.js stream that generates DTMF tones
npm install dtmf-generation-streamThis is a simple nodejs module that implements a readable stream that generates DTMF tones.
You can specify digits to be generated as a simple string like '1234' or use SSML like this:
```
npm i dtmf-generation-stream
`
Sample Usage
`
const DtmfGenerationStream = require('dtmf-generation-stream')
const Speaker = require('speaker')const format = {
sampleRate: 8000,
bitDepth: 16,
channels: 1
}
const dgs = new DtmfGenerationStream({format})
const s = new Speaker(format)
var digits = '11112222'
console.log(
Enqueueing: ${digits})
dgs.enqueue(digits)var ssml = '1234 1234 '
console.log(
Enqueueing: ${ssml})
dgs.enqueue(ssml)dgs.pipe(s)
dgs.on('empty', () => {
var ssml = 'abcd '
console.log(
Empty. Enqueueing: ${ssml})
dgs.enqueue(ssml)
})
``See here.
The stream emits event 'empty' indicating when there are no more digits in the queue to be played.