You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

dtmf-generation-stream

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dtmf-generation-stream

A node.js stream that generates DTMF tones

1.13.0
latest
Source
npmnpm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

dtmf-generation-stream

Overview

This 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:

<speak><prosody rate="50ms">1234</prosody><break time="500ms"/><prosody rate="100ms">1234</prosody></speak>

Installation

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 = '<speak><prosody rate="50ms">1234</prosody><break time="500ms"/><prosody rate="100ms">1234</prosody></speak>'
console.log(`Enqueueing: ${ssml}`)
dgs.enqueue(ssml)

dgs.pipe(s)

dgs.on('empty', () => {
  var ssml = '<speak><prosody rate="30ms">abcd</prosody></speak>'
  console.log(`Empty. Enqueueing: ${ssml}`)
  dgs.enqueue(ssml)
})

More Examples

See here.

Events

The stream emits event 'empty' indicating when there are no more digits in the queue to be played.

FAQs

Package last updated on 11 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts