***
id: 456d5aaa-fe93-4dec-9f93-3adc610dd07f
title: Types
keywords: 'SignalWire, Realtime SDK, Node.js, voice types, TypeScript types'
slug: /node/reference/voice/types
description: >-
Voice namespace type definitions including SIP headers, codecs, call
directions, device types, and voice language options for text-to-speech.
max-toc-depth: 3
----------------
[callstate]: /docs/server-sdk/v4/node/reference/voice/call-state
[devicebuilder-add]: /docs/server-sdk/v4/node/reference/voice/device-builder#add
[devicebuilder-phone]: /docs/server-sdk/v4/node/reference/voice/device-builder#phone
[devicebuilder-sip]: /docs/server-sdk/v4/node/reference/voice/device-builder#sip
[here]: /docs/platform/voice/tts
[sipcodec]: #sipcodec
[sipheader]: #sipheader
[voice-call]: /docs/server-sdk/v4/node/reference/voice/call/tap
Helper types.
### CollectDigitsConfig
A configuration object to specify how to collect digits.
Object containing the digit collection configuration.
Max number of digits to collect.
Timeout in seconds between each digit.
DTMF digits that will end the collection.
#### Example
Collecting digits using `call.collect()`:
```js
const collectObj = await call.collect({
digits: {
max: 4,
digitTimeout: 5,
terminators: "#"
}
});
const { digits, terminator } = await collectObj.ended();
```
Prompting for digits with TTS using `call.promptTTS()`:
```js
const prompt = await call.promptTTS({
text: "Please enter your 4-digit PIN",
digits: {
max: 4,
digitTimeout: 5,
terminators: "#*"
}
});
const { type, digits, terminator } = await prompt.ended();
```
***
### CollectSpeechConfig
A configuration object to specify how to collect speech.
Object containing the speech collection configuration.
How much silence to wait for end of speech in seconds.
Maximum time to collect speech in seconds.
Language to detect. Supported languages [here][here].
Array of expected phrases to detect.
Enable enhanced speech recognition at an additional cost. Accepted values are `enhanced`, `enhanced.phone_call`, or `enhanced.video`. The value `enhanced` will automatically detect whether to optimize with the `phone_call` or `video` setting.
#### Example
Collecting speech using `call.collect()`:
```js
const collectObj = await call.collect({
speech: {
endSilenceTimeout: 2,
speechTimeout: 30,
language: "en-US",
hints: ["yes", "no", "maybe"]
}
});
const { speech, text } = await collectObj.ended();
```
Prompting for speech with TTS using `call.promptTTS()`:
```js
const prompt = await call.promptTTS({
text: "Please say yes or no",
speech: {
endSilenceTimeout: 1,
speechTimeout: 60,
language: "en-US",
hints: ["yes", "no"]
}
});
const { type, text } = await prompt.ended();
```
***
### SipCodec
A codec for SIP. Possible values are: `"PCMU"`, `"PCMA"`, `"OPUS"`, `"G729"`, `"G722"`, `"VP8"`, `"H264"`.
#### Example
Using codecs when dialing a SIP endpoint with `Voice.DeviceBuilder.Sip()`:
```js
import { Voice } from "@signalwire/realtime-api";
const devices = new Voice.DeviceBuilder().add(
Voice.DeviceBuilder.Sip({
from: "sip:user1@domain.com",
to: "sip:user2@domain.com",
codecs: ["OPUS", "PCMU"]
})
);
const call = await client.voice.dial({ devices });
```
***
### SipHeader
A header for SIP. It is an object with the following properties.
#### Properties
Name of the header.
Value of the header.
#### Example
Using custom headers when dialing a SIP endpoint with `Voice.DeviceBuilder.Sip()`:
```js
import { Voice } from "@signalwire/realtime-api";
const devices = new Voice.DeviceBuilder().add(
Voice.DeviceBuilder.Sip({
from: "sip:user1@domain.com",
to: "sip:user2@domain.com",
headers: [
{ name: "X-Custom-Header", value: "my-value" },
{ name: "X-Account-ID", value: "12345" }
]
})
);
const call = await client.voice.dial({ devices });
```
***
### RingtoneName
The name of a ringtone, based on country-specific ring patterns.
| Value | Country |
| :---- | :------------- |
| `at` | Austria |
| `au` | Australia |
| `be` | Belgium |
| `bg` | Bulgaria |
| `br` | Brazil |
| `ch` | Switzerland |
| `cl` | Chile |
| `cn` | China |
| `cz` | Czech Republic |
| `de` | Germany |
| `dk` | Denmark |
| `ee` | Estonia |
| `es` | Spain |
| `fi` | Finland |
| `fr` | France |
| `gr` | Greece |
| `hu` | Hungary |
| `il` | Israel |
| `in` | India |
| `it` | Italy |
| `jp` | Japan |
| `lt` | Lithuania |
| `mx` | Mexico |
| `my` | Malaysia |
| `nl` | Netherlands |
| `no` | Norway |
| `nz` | New Zealand |
| `ph` | Philippines |
| `pl` | Poland |
| `pt` | Portugal |
| `ru` | Russia |
| `se` | Sweden |
| `sg` | Singapore |
| `th` | Thailand |
| `tw` | Taiwan |
| `uk` | United Kingdom |
| `us` | United States |
| `ve` | Venezuela |
| `za` | South Africa |
#### Example
Playing a ringtone with `Voice.Playlist.Ringtone()`:
```js
import { Voice } from "@signalwire/realtime-api";
const playlist = new Voice.Playlist()
.add(Voice.Playlist.Ringtone({ name: "us", duration: 10 }));
await call.play(playlist);
```
Prompting with a ringtone using `call.promptRingtone()`:
```js
const prompt = await call.promptRingtone({
name: "it",
duration: 10,
digits: {
max: 1,
digitTimeout: 5
}
});
const { digits } = await prompt.ended();
```
***
### VoiceCallPhoneParams
A device configuration object for calling a phone number. Returned by [`Voice.DeviceBuilder.Phone()`][devicebuilder-phone] and passed to [`DeviceBuilder.add()`][devicebuilder-add].
#### Properties
The device type. Always `"phone"` for phone devices.
Number to call, in E.164 format.
SignalWire number to use to initiate the call, in E.164 format.
Time to wait for the call to be answered, in seconds.
Webhook URL to which SignalWire will send call status change notifications. See [`CallState`][callstate].
Array of event names to be notified about. Allowed values are `created`, `ringing`, `answered`, and `ended`.
### VoiceCallSipParams
A device configuration object for calling a SIP endpoint. Returned by [`Voice.DeviceBuilder.Sip()`][devicebuilder-sip] and passed to [`DeviceBuilder.add()`][devicebuilder-add].
#### Properties
The device type. Always `"sip"` for SIP devices.
SIP endpoint URI to call.
SIP endpoint URI to use to initiate the call.
Time to wait for the call to be answered, in seconds.
Array of desired codecs in order of preference. See [`SipCodec`][sipcodec].
Array of headers. Must be X- headers only. See [`SipHeader`][sipheader].
Webhook URL to which SignalWire will send call status change notifications. See [`CallState`][callstate].
Array of event names to be notified about. Allowed values are `created`, `ringing`, `answered`, and `ended`.
Whether to use WebRTC media.
Session timeout in seconds.
### TapDevice
A device to use as a destination for [`tap`][voice-call].
This can be either an RTP device or a WebSocket device.
#### Properties
Type of this device (RTP or WebSocket).
**RTP** (`type` = `"rtp"`)
An RTP device has the following properties in addition to the general ones:
RTP IPv4 address.
RTP port.
Optional codec to use. It will be the same as the tapped audio if not set.
Optional sample rate in Hz. It will be the same as the tapped audio if not set.
Optional packetization time in milliseconds. It will be the same as the tapped audio if not set.
**WebSocket** (`type` = `"ws"`)
A WebSocket device has the following properties in addition to the general ones:
Destination URI.
Optional codec to use. It will be the same as the tapped audio if not set.
Optional sample rate in Hz. It will be the same as the tapped audio if not set.
#### Example
Tapping audio to a WebSocket endpoint using `call.tapAudio()`:
```js
const tap = await call.tapAudio({
direction: "both",
device: {
type: "ws",
uri: "wss://example.domain.com/endpoint"
}
});
// Stop the tap when done
await tap.stop();
```
Tapping audio to an RTP endpoint using `call.tap()`:
```js
const tap = await call.tap({
audio: {
direction: "speak"
},
device: {
type: "rtp",
addr: "192.0.2.1",
port: "1234",
codec: "PCMU"
}
});
await tap.stop();
```