@fonoster/voice 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +395 -2
- package/dist/demo.js +26 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/types.d.ts +1 -1
- package/dist/verbs/index.d.ts +2 -2
- package/dist/verbs/index.js +2 -2
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,3 +1,396 @@
|
|
|
1
|
-
|
|
1
|
+
voice
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
[](https://fonoster.com)
|
|
5
|
+
[](https://npmjs.org/package/@fonoster/voice)
|
|
6
|
+
[](https://npmjs.org/package/@fonoster/voice)
|
|
7
|
+
[](https://github.com/fonoster/fonoster/blob/main/package.json)
|
|
8
|
+
|
|
9
|
+
The Voice module is a library for creating voice applications using the Fonoster API. It provides a simple way to create voice applications that can interact with the calling party using DTMF or speech recognition combined with simple verbs.
|
|
10
|
+
|
|
11
|
+
* [Installation](#installation)
|
|
12
|
+
* [Example](#example)
|
|
13
|
+
* [Voice Response](#VoiceResponse)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```sh-session
|
|
18
|
+
$ npm install --save @fonoster/voice
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
A Voice Application is a server that controls a call's flow. A Voice Application can use any combination of the following verbs:
|
|
24
|
+
|
|
25
|
+
- `Answer` - Accepts an incoming call
|
|
26
|
+
- `Dial` - Passes the call to an Agent or a Number at the PSTN
|
|
27
|
+
- `Hangup` - Closes the call
|
|
28
|
+
- `Play` - Takes a URL or file and streams the sound back to the calling party
|
|
29
|
+
- `Say` - Takes a text, synthesizes the text into audio, and streams back the result
|
|
30
|
+
- `Gather` - Waits for DTMF or speech events and returns back the result
|
|
31
|
+
- `SGather` - Returns a stream for future DTMF and speech results
|
|
32
|
+
- `Stream` - Starts a stream to read and write audio into the call
|
|
33
|
+
- `Record` - It records the voice of the calling party and saves the audio on the Storage sub-system
|
|
34
|
+
- `Mute` - It tells the channel to stop sending media, effectively muting the channel
|
|
35
|
+
- `Unmute` - It tells the channel to allow media flow
|
|
36
|
+
|
|
37
|
+
Voice Application Example:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const VoiceServer = require("@fonoster/voice").default;
|
|
41
|
+
const {
|
|
42
|
+
GatherSource,
|
|
43
|
+
VoiceRequest,
|
|
44
|
+
VoiceResponse
|
|
45
|
+
} = require("@fonoster/voice");
|
|
46
|
+
|
|
47
|
+
new VoiceServer().listen(async (req: VoiceRequest, voice: VoiceResponse) => {
|
|
48
|
+
const { ingressNumber, sessionRef, appRef } = req;
|
|
49
|
+
|
|
50
|
+
await voice.answer();
|
|
51
|
+
|
|
52
|
+
await voice.say("Hi there! What's your name?");
|
|
53
|
+
|
|
54
|
+
const { speech: name } = await res.gather({
|
|
55
|
+
source: GatherSource.SPEECH
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
await voice.say("Nice to meet you " + name + "!");
|
|
59
|
+
|
|
60
|
+
await voice.say("Please enter your 4 digit pin.");
|
|
61
|
+
|
|
62
|
+
const { digits } = await voice.gather({
|
|
63
|
+
maxDigits: 4,
|
|
64
|
+
finishOnKey: "#"
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await voice.say("Your pin is " + digits);
|
|
68
|
+
|
|
69
|
+
await voice.hangup();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Your app will live at tcp://127.0.0.1:50061
|
|
73
|
+
// and you can easily publish it to the Internet with:
|
|
74
|
+
// ngrok tcp 50061
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
<a name="VoiceResponse"></a>
|
|
78
|
+
|
|
79
|
+
## VoiceResponse ⇐ <code>Verb</code>
|
|
80
|
+
Use the VoiceResponse object, to construct advance Interactive
|
|
81
|
+
Voice Response (IVR) applications.
|
|
82
|
+
|
|
83
|
+
**Kind**: global class
|
|
84
|
+
**Extends**: <code>Verb</code>
|
|
85
|
+
**See**: module:core:APIClient
|
|
86
|
+
|
|
87
|
+
* [VoiceResponse](#VoiceResponse) ⇐ <code>Verb</code>
|
|
88
|
+
* [new VoiceResponse(request, voice)](#new_VoiceResponse_new)
|
|
89
|
+
* [.answer()](#VoiceResponse+answer)
|
|
90
|
+
* [.hangup()](#VoiceResponse+hangup)
|
|
91
|
+
* [.play(url, options)](#VoiceResponse+play)
|
|
92
|
+
* [.playDtmf(digits)](#VoiceResponse+playDtmf)
|
|
93
|
+
* [.playbackControl(playbackRef, action)](#VoiceResponse+playbackControl)
|
|
94
|
+
* [.gather(options)](#VoiceResponse+gather)
|
|
95
|
+
* [.say(text, options)](#VoiceResponse+say)
|
|
96
|
+
* [.record(options)](#VoiceResponse+record) ⇒ <code>RecordResponse</code>
|
|
97
|
+
* [.dial(destination, options)](#VoiceResponse+dial) ⇒ <code>Promise.<DialStatusStream></code>
|
|
98
|
+
* [.stream(options)](#VoiceResponse+stream) ⇒ <code>Promise.<Stream></code>
|
|
99
|
+
* [.sgather(options)](#VoiceResponse+sgather) ⇒ <code>Promise.<StreamGatherStream></code>
|
|
100
|
+
* [.mute(options)](#VoiceResponse+mute)
|
|
101
|
+
* [.unmute(options)](#VoiceResponse+unmute)
|
|
102
|
+
|
|
103
|
+
<a name="new_VoiceResponse_new"></a>
|
|
104
|
+
|
|
105
|
+
### new VoiceResponse(request, voice)
|
|
106
|
+
Constructs a new VoiceResponse object.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
| Param | Type | Description |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| request | <code>VoiceRequest</code> | Options to indicate the objects endpoint |
|
|
112
|
+
| voice | <code>VoiceSessionStream</code> | The voice session stream |
|
|
113
|
+
|
|
114
|
+
**Example**
|
|
115
|
+
```js
|
|
116
|
+
import { VoiceServer } from "@fonoster/voice";
|
|
117
|
+
|
|
118
|
+
async function handler (request, response) {
|
|
119
|
+
await response.answer();
|
|
120
|
+
await response.play("https://soundsserver:9000/sounds/hello-world.wav");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
new VoiceServer().listen(handler, { port: 3000 })
|
|
124
|
+
```
|
|
125
|
+
<a name="VoiceResponse+answer"></a>
|
|
126
|
+
|
|
127
|
+
### voiceResponse.answer()
|
|
128
|
+
Answer the call. Before running any other verb you
|
|
129
|
+
must run the anwer command.
|
|
130
|
+
|
|
131
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
132
|
+
**Example**
|
|
133
|
+
```js
|
|
134
|
+
async function handler (request, response) {
|
|
135
|
+
await response.answer();
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
<a name="VoiceResponse+hangup"></a>
|
|
139
|
+
|
|
140
|
+
### voiceResponse.hangup()
|
|
141
|
+
Hangup the call.
|
|
142
|
+
|
|
143
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
144
|
+
**Example**
|
|
145
|
+
```js
|
|
146
|
+
async function handler (request, response) {
|
|
147
|
+
await response.hangup();
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
<a name="VoiceResponse+play"></a>
|
|
151
|
+
|
|
152
|
+
### voiceResponse.play(url, options)
|
|
153
|
+
Play an audio in the call.
|
|
154
|
+
|
|
155
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
156
|
+
**See**: Playback
|
|
157
|
+
|
|
158
|
+
| Param | Type | Description |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| url | <code>string</code> | The URL of the media to play |
|
|
161
|
+
| options | <code>PlayOptions</code> | Options to control the playback |
|
|
162
|
+
| options.playbackRef | <code>string</code> | Playback identifier to use in Playback operations |
|
|
163
|
+
|
|
164
|
+
**Example**
|
|
165
|
+
```js
|
|
166
|
+
async function handler (request, response) {
|
|
167
|
+
await response.answer();
|
|
168
|
+
await response.play("https://soundsserver:9000/sounds/hello-world.wav");
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
<a name="VoiceResponse+playDtmf"></a>
|
|
172
|
+
|
|
173
|
+
### voiceResponse.playDtmf(digits)
|
|
174
|
+
Play a series of DTMF digits in a call.
|
|
175
|
+
|
|
176
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
177
|
+
|
|
178
|
+
| Param | Type | Description |
|
|
179
|
+
| --- | --- | --- |
|
|
180
|
+
| digits | <code>string</code> | The DTMF digits to play (0-9, #, or *) |
|
|
181
|
+
|
|
182
|
+
**Example**
|
|
183
|
+
```js
|
|
184
|
+
async function handler (request, response) {
|
|
185
|
+
await response.answer();
|
|
186
|
+
await response.playDtmf("1234");
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
<a name="VoiceResponse+playbackControl"></a>
|
|
190
|
+
|
|
191
|
+
### voiceResponse.playbackControl(playbackRef, action)
|
|
192
|
+
Control the playback of the currently playing media.
|
|
193
|
+
|
|
194
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
195
|
+
**See**: play
|
|
196
|
+
|
|
197
|
+
| Param | Type | Description |
|
|
198
|
+
| --- | --- | --- |
|
|
199
|
+
| playbackRef | <code>string</code> | The playback identifier |
|
|
200
|
+
| action | <code>PlaybackControlAction</code> | The action to perform (STOP, RESTART, PAUSE, UNPAUSE, FORWARD) |
|
|
201
|
+
|
|
202
|
+
**Example**
|
|
203
|
+
```js
|
|
204
|
+
async function handler (request, response) {
|
|
205
|
+
await response.answer();
|
|
206
|
+
await response.play("https://s3.fonoster.io/uuid/hello-world.wav", { playbackRef: "playback-01" });
|
|
207
|
+
|
|
208
|
+
// Pause the media
|
|
209
|
+
await response.playbackControl("playback-01", PlaybackControlAction.PAUSE);
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
<a name="VoiceResponse+gather"></a>
|
|
213
|
+
|
|
214
|
+
### voiceResponse.gather(options)
|
|
215
|
+
Waits for data entry from the user's keypad or from a speech provider.
|
|
216
|
+
|
|
217
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
218
|
+
**Note**: When including `SPEECH` the default timeout is 10000 (10s).
|
|
219
|
+
|
|
220
|
+
| Param | Type | Description |
|
|
221
|
+
| --- | --- | --- |
|
|
222
|
+
| options | <code>GatherOptions</code> | Options to select the maximum number of digits, final character, and timeout |
|
|
223
|
+
| options.maxDigits | <code>number</code> | Maximum number of digits to collect. Defaults to 1 |
|
|
224
|
+
| options.timeout | <code>number</code> | Milliseconds to wait before timeout. Defaults to 4000. Use zero for no timeout. |
|
|
225
|
+
| options.finishOnKey | <code>string</code> | Optional last character to wait for. Defaults to '#'. It will not be included in the returned digits |
|
|
226
|
+
| options.source | <code>GatherSource</code> | Where to listen as input source. This option accepts `DTMF` and `SPEECH`. A speech provider must be configure when including the `SPEECH` source. You might inclue both with `SPEECH_AND_DTMF`. Defaults to `SPEECH_AND_DTMF` |
|
|
227
|
+
|
|
228
|
+
**Example**
|
|
229
|
+
```js
|
|
230
|
+
async function handler (request, response) {
|
|
231
|
+
await response.answer();
|
|
232
|
+
const speech = await response.gather({ source: GatherSource.SPEECH, numDigits: 3 });
|
|
233
|
+
console.log("speech: " + speech);
|
|
234
|
+
await response.hangup();
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
<a name="VoiceResponse+say"></a>
|
|
238
|
+
|
|
239
|
+
### voiceResponse.say(text, options)
|
|
240
|
+
Send a text for a TTS engine to convert to speech.
|
|
241
|
+
|
|
242
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
243
|
+
**See**: Say
|
|
244
|
+
|
|
245
|
+
| Param | Type | Description |
|
|
246
|
+
| --- | --- | --- |
|
|
247
|
+
| text | <code>string</code> | The text to convert to speech |
|
|
248
|
+
| options | <code>SayOptions</code> | Options to control the TTS engine |
|
|
249
|
+
| options.playbackRef | <code>string</code> | Playback identifier to use in Playback operations |
|
|
250
|
+
| options.ttsOptions | <code>TTSOptions</code> | Options to control the TTS engine (specific to the TTS engine) |
|
|
251
|
+
|
|
252
|
+
**Example**
|
|
253
|
+
```js
|
|
254
|
+
async function handler (request, response) {
|
|
255
|
+
await response.answer();
|
|
256
|
+
const playbackRef = await response.say("Hello World");
|
|
257
|
+
|
|
258
|
+
// Like the play verb, you can control the playback
|
|
259
|
+
await response.playbackControl(playbackRef, PlaybackControlAction.STOP);
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
<a name="VoiceResponse+record"></a>
|
|
263
|
+
|
|
264
|
+
### voiceResponse.record(options) ⇒ <code>RecordResponse</code>
|
|
265
|
+
Record the audio of the call.
|
|
266
|
+
|
|
267
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
268
|
+
**Returns**: <code>RecordResponse</code> - The record response
|
|
269
|
+
|
|
270
|
+
| Param | Type | Description |
|
|
271
|
+
| --- | --- | --- |
|
|
272
|
+
| options | <code>RecordOptions</code> | Options to control the record operation |
|
|
273
|
+
| options.maxDuration | <code>number</code> | The maximum duration of the recording in seconds. Default is 60 |
|
|
274
|
+
| options.maxSilence | <code>number</code> | The maximum duration of silence in seconds. Default is 5 |
|
|
275
|
+
| options.beep | <code>boolean</code> | Play a beep before recording. Default is true |
|
|
276
|
+
| options.finishOnKey | <code>string</code> | Stop recording when a DTMF digit is received. Default is '#' |
|
|
277
|
+
|
|
278
|
+
**Example**
|
|
279
|
+
```js
|
|
280
|
+
async function handler (request, response) {
|
|
281
|
+
await response.answer();
|
|
282
|
+
const record = await response.record();
|
|
283
|
+
console.log("Recording: %s", record.name);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
<a name="VoiceResponse+dial"></a>
|
|
287
|
+
|
|
288
|
+
### voiceResponse.dial(destination, options) ⇒ <code>Promise.<DialStatusStream></code>
|
|
289
|
+
Dials a destination and returns a stream of status.
|
|
290
|
+
|
|
291
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
292
|
+
**Returns**: <code>Promise.<DialStatusStream></code> - The dial status stream
|
|
293
|
+
|
|
294
|
+
| Param | Type | Description |
|
|
295
|
+
| --- | --- | --- |
|
|
296
|
+
| destination | <code>string</code> | The destination to dial |
|
|
297
|
+
| options | <code>DialOptions</code> | Options to control the dial operation |
|
|
298
|
+
| options.timeout | <code>number</code> | The timeout in seconds. Default is 60 |
|
|
299
|
+
| options.recordDirection | <code>RecordDirection</code> | The direction to record the call (IN, OUT, BOTH). Default is BOTH |
|
|
300
|
+
|
|
301
|
+
<a name="VoiceResponse+stream"></a>
|
|
302
|
+
|
|
303
|
+
### voiceResponse.stream(options) ⇒ <code>Promise.<Stream></code>
|
|
304
|
+
Starts a bidirectional audio stream between the call and the application.
|
|
305
|
+
|
|
306
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
307
|
+
**Returns**: <code>Promise.<Stream></code> - The stream object
|
|
308
|
+
|
|
309
|
+
| Param | Type | Description |
|
|
310
|
+
| --- | --- | --- |
|
|
311
|
+
| options | <code>StreamOptions</code> | Options to control the stream operation |
|
|
312
|
+
| options.direction | <code>StreamDirection</code> | The direction to stream the audio (IN, OUT, BOTH). Default is BOTH |
|
|
313
|
+
| options.format | <code>StreamAudioFormat</code> | The audio format to stream (WAV). Default is WAV |
|
|
314
|
+
|
|
315
|
+
**Example**
|
|
316
|
+
```js
|
|
317
|
+
async function handler (request, response) {
|
|
318
|
+
await response.answer();
|
|
319
|
+
|
|
320
|
+
const stream = await response.stream({
|
|
321
|
+
direction: StreamDirection.BOTH
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
stream.onPayload((payload) => {
|
|
325
|
+
// Use the payload
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Or write to the stream
|
|
329
|
+
// stream.write({ type: StreamMessageType.AUDIO_OUT, payload: "\x00\x01\x02" });
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
<a name="VoiceResponse+sgather"></a>
|
|
333
|
+
|
|
334
|
+
### voiceResponse.sgather(options) ⇒ <code>Promise.<StreamGatherStream></code>
|
|
335
|
+
Starts a server-side stream gather operation which sends transcription data to the voice server.
|
|
336
|
+
|
|
337
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
338
|
+
**Returns**: <code>Promise.<StreamGatherStream></code> - The stream gather object
|
|
339
|
+
**See**: Gather
|
|
340
|
+
|
|
341
|
+
| Param | Type | Description |
|
|
342
|
+
| --- | --- | --- |
|
|
343
|
+
| options | <code>StreamGatherOptions</code> | Options to control the stream gather operation |
|
|
344
|
+
| options.source | <code>StreamGatherSource</code> | The source to gather data from (DTMF, SPEECH, SPEECH_AND_DTMF). Default is SPEECH |
|
|
345
|
+
|
|
346
|
+
**Example**
|
|
347
|
+
```js
|
|
348
|
+
async function handler (request, response) {
|
|
349
|
+
await response.answer();
|
|
350
|
+
const sGather = await response.streamGather({ source: StreamGatherSource.SPEECH });
|
|
351
|
+
sGather.onPayload((payload) => {
|
|
352
|
+
console.log("Payload: %s", payload);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
<a name="VoiceResponse+mute"></a>
|
|
357
|
+
|
|
358
|
+
### voiceResponse.mute(options)
|
|
359
|
+
Mutes a call.
|
|
360
|
+
|
|
361
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
362
|
+
**See**: unmute
|
|
363
|
+
|
|
364
|
+
| Param | Type | Description |
|
|
365
|
+
| --- | --- | --- |
|
|
366
|
+
| options | <code>MuteOptions</code> | Options to control the mute operation |
|
|
367
|
+
| options.direction | <code>MuteDirection</code> | The direction to mute the channel (IN, OUT, BOTH). Default is BOTH |
|
|
368
|
+
|
|
369
|
+
**Example**
|
|
370
|
+
```js
|
|
371
|
+
async function handler (request, response) {
|
|
372
|
+
await response.answer();
|
|
373
|
+
await response.mute(); // Will mute both directions
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
<a name="VoiceResponse+unmute"></a>
|
|
377
|
+
|
|
378
|
+
### voiceResponse.unmute(options)
|
|
379
|
+
Unmutes a call.
|
|
380
|
+
|
|
381
|
+
**Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
|
|
382
|
+
**See**: mute
|
|
383
|
+
|
|
384
|
+
| Param | Type | Description |
|
|
385
|
+
| --- | --- | --- |
|
|
386
|
+
| options | <code>MuteOptions</code> | Options to control the unmute operation |
|
|
387
|
+
| options.direction | <code>MuteDirection</code> | The direction to unmute the call (IN, OUT, BOTH). Default is BOTH |
|
|
388
|
+
|
|
389
|
+
**Example**
|
|
390
|
+
```js
|
|
391
|
+
async function handler (request, response) {
|
|
392
|
+
await response.answer();
|
|
393
|
+
await response.unmute(); // Will unmute both directions
|
|
394
|
+
}
|
|
395
|
+
```
|
|
2
396
|
|
|
3
|
-
This module is part of the [Fonoster](https://fonoster.com) project. By itself, it does not do much. It is intended to be used as a dependency for other modules. For more information about the project, please visit [https://github.com/fonoster/fonoster](https://github.com/fonoster/fonoster).
|
package/dist/demo.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,9 +31,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
35
|
/*
|
|
16
36
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
@@ -30,19 +50,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
50
|
* See the License for the specific language governing permissions and
|
|
31
51
|
* limitations under the License.
|
|
32
52
|
*/
|
|
33
|
-
const common_1 = require("@fonoster/common");
|
|
34
53
|
const logger_1 = require("@fonoster/logger");
|
|
35
|
-
const
|
|
54
|
+
const _1 = __importStar(require("."));
|
|
36
55
|
const logger = (0, logger_1.getLogger)({ service: "voice", filePath: __filename });
|
|
37
56
|
const skipIdentity = process.env.NODE_ENV === "dev";
|
|
38
57
|
// Only skip identity for local development
|
|
39
|
-
new
|
|
58
|
+
new _1.default({ skipIdentity }).listen((req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
59
|
const { ingressNumber, sessionRef, appRef } = req;
|
|
41
60
|
logger.verbose("voice request", { ingressNumber, sessionRef, appRef });
|
|
42
61
|
yield res.answer();
|
|
43
62
|
yield res.say("Hi there! What's your name?");
|
|
44
63
|
const { speech: name } = yield res.gather({
|
|
45
|
-
source:
|
|
64
|
+
source: _1.GatherSource.SPEECH
|
|
46
65
|
});
|
|
47
66
|
yield res.say("Nice to meet you " + name + "!");
|
|
48
67
|
yield res.say("Please enter your 4 digit pin.");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { AzureVoice, AzureVoiceDetails, GoogleVoice, GoogleVoiceDetails } from "@fonoster/common";
|
|
2
|
+
import { AzureVoice, AzureVoiceDetails, GatherSource, GoogleVoice, GoogleVoiceDetails, StreamGatherSource } from "@fonoster/common";
|
|
3
3
|
import VoiceServer from "./VoiceServer";
|
|
4
4
|
export default VoiceServer;
|
|
5
5
|
export * from "./VoiceResponse";
|
|
6
6
|
export * from "./types";
|
|
7
|
-
export { GoogleVoice, GoogleVoiceDetails,
|
|
7
|
+
export { AzureVoice, AzureVoiceDetails, GatherSource, GoogleVoice, GoogleVoiceDetails, StreamGatherSource };
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
21
|
+
exports.StreamGatherSource = exports.GoogleVoiceDetails = exports.GoogleVoice = exports.GatherSource = exports.AzureVoiceDetails = exports.AzureVoice = void 0;
|
|
22
22
|
/*
|
|
23
23
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
24
24
|
* http://github.com/fonoster/fonoster
|
|
@@ -40,8 +40,10 @@ exports.AzureVoiceDetails = exports.AzureVoice = exports.GoogleVoiceDetails = ex
|
|
|
40
40
|
const common_1 = require("@fonoster/common");
|
|
41
41
|
Object.defineProperty(exports, "AzureVoice", { enumerable: true, get: function () { return common_1.AzureVoice; } });
|
|
42
42
|
Object.defineProperty(exports, "AzureVoiceDetails", { enumerable: true, get: function () { return common_1.AzureVoiceDetails; } });
|
|
43
|
+
Object.defineProperty(exports, "GatherSource", { enumerable: true, get: function () { return common_1.GatherSource; } });
|
|
43
44
|
Object.defineProperty(exports, "GoogleVoice", { enumerable: true, get: function () { return common_1.GoogleVoice; } });
|
|
44
45
|
Object.defineProperty(exports, "GoogleVoiceDetails", { enumerable: true, get: function () { return common_1.GoogleVoiceDetails; } });
|
|
46
|
+
Object.defineProperty(exports, "StreamGatherSource", { enumerable: true, get: function () { return common_1.StreamGatherSource; } });
|
|
45
47
|
const VoiceServer_1 = __importDefault(require("./VoiceServer"));
|
|
46
48
|
exports.default = VoiceServer_1.default;
|
|
47
49
|
__exportStar(require("./VoiceResponse"), exports);
|
package/dist/types.d.ts
CHANGED
package/dist/verbs/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from "./Answer";
|
|
2
|
+
export * from "./Dial";
|
|
2
3
|
export * from "./Gather";
|
|
3
4
|
export * from "./Hangup";
|
|
4
5
|
export * from "./Mute";
|
|
5
|
-
export * from "./Dial";
|
|
6
6
|
export * from "./Play";
|
|
7
7
|
export * from "./PlayDtmf";
|
|
8
8
|
export * from "./PlaybackControl";
|
|
@@ -11,5 +11,5 @@ export * from "./Say";
|
|
|
11
11
|
export * from "./Stream";
|
|
12
12
|
export * from "./StreamGather";
|
|
13
13
|
export * from "./Unmute";
|
|
14
|
-
export * from "./validateRequest";
|
|
15
14
|
export * from "./Verb";
|
|
15
|
+
export * from "./validateRequest";
|
package/dist/verbs/index.js
CHANGED
|
@@ -33,10 +33,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
* limitations under the License.
|
|
34
34
|
*/
|
|
35
35
|
__exportStar(require("./Answer"), exports);
|
|
36
|
+
__exportStar(require("./Dial"), exports);
|
|
36
37
|
__exportStar(require("./Gather"), exports);
|
|
37
38
|
__exportStar(require("./Hangup"), exports);
|
|
38
39
|
__exportStar(require("./Mute"), exports);
|
|
39
|
-
__exportStar(require("./Dial"), exports);
|
|
40
40
|
__exportStar(require("./Play"), exports);
|
|
41
41
|
__exportStar(require("./PlayDtmf"), exports);
|
|
42
42
|
__exportStar(require("./PlaybackControl"), exports);
|
|
@@ -45,5 +45,5 @@ __exportStar(require("./Say"), exports);
|
|
|
45
45
|
__exportStar(require("./Stream"), exports);
|
|
46
46
|
__exportStar(require("./StreamGather"), exports);
|
|
47
47
|
__exportStar(require("./Unmute"), exports);
|
|
48
|
-
__exportStar(require("./validateRequest"), exports);
|
|
49
48
|
__exportStar(require("./Verb"), exports);
|
|
49
|
+
__exportStar(require("./validateRequest"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/voice",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Voice Server for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -14,14 +14,15 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
16
16
|
"build": "tsc -b tsconfig.json",
|
|
17
|
-
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
|
|
17
|
+
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo",
|
|
18
|
+
"generate:readme": "node ../../.scripts/gen-readme.js"
|
|
18
19
|
},
|
|
19
20
|
"bin": {
|
|
20
21
|
"fonoster": "./dist/index.js"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@fonoster/common": "^0.7.
|
|
24
|
-
"@fonoster/logger": "^0.7.
|
|
24
|
+
"@fonoster/common": "^0.7.5",
|
|
25
|
+
"@fonoster/logger": "^0.7.5",
|
|
25
26
|
"@grpc/grpc-js": "~1.10.6",
|
|
26
27
|
"deepmerge": "^4.3.1",
|
|
27
28
|
"grpc-health-check": "^2.0.2",
|
|
@@ -42,5 +43,5 @@
|
|
|
42
43
|
"bugs": {
|
|
43
44
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
44
45
|
},
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "cf28444503e4e698ccc001e061c7c918a4204757"
|
|
46
47
|
}
|