sip-lab 1.22.0 → 1.24.0
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 +5 -4
- package/binding.gyp +4 -0
- package/build_deps.sh +21 -1
- package/index.js +19 -0
- package/package.json +3 -2
- package/pocketsphinx/model/CMakeLists.txt +3 -0
- package/pocketsphinx/model/en-us/cmudict-en-us.dict +134782 -0
- package/pocketsphinx/model/en-us/en-us/README +34 -0
- package/pocketsphinx/model/en-us/en-us/feat.params +12 -0
- package/pocketsphinx/model/en-us/en-us/mdef +0 -0
- package/pocketsphinx/model/en-us/en-us/means +0 -0
- package/pocketsphinx/model/en-us/en-us/noisedict +5 -0
- package/pocketsphinx/model/en-us/en-us/sendump +0 -0
- package/pocketsphinx/model/en-us/en-us/transition_matrices +0 -0
- package/pocketsphinx/model/en-us/en-us/variances +0 -0
- package/pocketsphinx/model/en-us/en-us-phone.lm.bin +0 -0
- package/pocketsphinx/model/en-us/en-us.lm.bin +0 -0
- package/prebuilds/linux-x64/sip-lab.node +0 -0
- package/samples/artifacts/hello_good_morning.wav +0 -0
- package/samples/play_wav_and_speech_recog.bad_transcript.pcmu8000.js +182 -0
- package/samples/speech_synth_and_recog.speex16000.js +186 -0
- package/samples/start_play_wav_with_end_of_file_event.js +269 -0
- package/samples/start_play_wav_with_no_loop.js +257 -0
- package/samples/tcp_and_extra_headers.js +47 -1
- package/samples/text_to_speech.js +22 -3
- package/src/addon.cpp +72 -0
- package/src/event_templates.cpp +20 -7
- package/src/event_templates.hpp +6 -0
- package/src/pjmedia/include/pjmedia/flite_port.h +10 -4
- package/src/pjmedia/include/pjmedia/pocketsphinx_port.h +19 -0
- package/src/pjmedia/src/pjmedia/flite_port.c +91 -25
- package/src/pjmedia/src/pjmedia/pocketsphinx_port.c +273 -0
- package/src/sip.cpp +707 -507
- package/src/sip.hpp +5 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* ====================================================================
|
|
2
|
+
* Copyright (c) 2015 Alpha Cephei Inc. All rights
|
|
3
|
+
* reserved.
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions
|
|
7
|
+
* are met:
|
|
8
|
+
*
|
|
9
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
*
|
|
12
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
* notice, this list of conditions and the following disclaimer in
|
|
14
|
+
* the documentation and/or other materials provided with the
|
|
15
|
+
* distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY ALPHA CEPHEI INC. ``AS IS'' AND.
|
|
18
|
+
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,.
|
|
19
|
+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ALPHA CEPHEI INC.
|
|
21
|
+
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT.
|
|
23
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,.
|
|
24
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY.
|
|
25
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT.
|
|
26
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE.
|
|
27
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
*
|
|
29
|
+
* ====================================================================
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
This directory contains generic US english acoustic model trained with
|
|
34
|
+
latest sphinxtrain.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
var sip = require ('../index.js')
|
|
2
|
+
var Zeq = require('@mayama/zeq')
|
|
3
|
+
var z = new Zeq()
|
|
4
|
+
var m = require('data-matching')
|
|
5
|
+
var sip_msg = require('sip-matching')
|
|
6
|
+
var sdp = require('sdp-matching')
|
|
7
|
+
|
|
8
|
+
async function test() {
|
|
9
|
+
//sip.set_log_level(6)
|
|
10
|
+
sip.dtmf_aggregation_on(500)
|
|
11
|
+
|
|
12
|
+
sip.set_codecs("pcmu/8000/1:128")
|
|
13
|
+
|
|
14
|
+
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
15
|
+
var e = evt.args[0]
|
|
16
|
+
return e
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
console.log(sip.start((data) => { console.log(data)} ))
|
|
20
|
+
|
|
21
|
+
t1 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
|
|
22
|
+
t2 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
|
|
23
|
+
|
|
24
|
+
console.log("t1", t1)
|
|
25
|
+
console.log("t2", t2)
|
|
26
|
+
|
|
27
|
+
oc = sip.call.create(t1.id, {
|
|
28
|
+
from_uri: '"abc"<sip:alice@test.com>',
|
|
29
|
+
to_uri: `sip:bob@${t2.address}:${t2.port}`,
|
|
30
|
+
headers: {
|
|
31
|
+
'X-MyHeader1': 'abc',
|
|
32
|
+
'X-MyHeader2': 'def',
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
await z.wait([
|
|
37
|
+
{
|
|
38
|
+
event: "incoming_call",
|
|
39
|
+
call_id: m.collect("call_id"),
|
|
40
|
+
msg: sip_msg({
|
|
41
|
+
$rm: 'INVITE',
|
|
42
|
+
$fU: 'alice',
|
|
43
|
+
$fd: 'test.com',
|
|
44
|
+
$tU: 'bob',
|
|
45
|
+
'$hdr(X-MyHeader1)': 'abc',
|
|
46
|
+
'hdr_x_myheader2': 'def',
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
event: 'response',
|
|
51
|
+
call_id: oc.id,
|
|
52
|
+
method: 'INVITE',
|
|
53
|
+
msg: sip_msg({
|
|
54
|
+
$rs: '100',
|
|
55
|
+
$rr: 'Trying',
|
|
56
|
+
'$(hdrcnt(via))': 1,
|
|
57
|
+
'hdr_call_id': m.collect('sip_call_id'),
|
|
58
|
+
$fU: 'alice',
|
|
59
|
+
$fd: 'test.com',
|
|
60
|
+
$tU: 'bob',
|
|
61
|
+
'$hdr(l)': '0',
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
], 1000)
|
|
65
|
+
|
|
66
|
+
ic = {
|
|
67
|
+
id: z.store.call_id,
|
|
68
|
+
sip_call_id: z.store.sip_call_id,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
sip.call.respond(ic.id, {
|
|
72
|
+
code: 200,
|
|
73
|
+
reason:'OK',
|
|
74
|
+
headers: {
|
|
75
|
+
'X-MyHeader3': 'ghi',
|
|
76
|
+
'X-MyHeader4': 'jkl',
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
await z.wait([
|
|
81
|
+
{
|
|
82
|
+
event: 'media_update',
|
|
83
|
+
call_id: oc.id,
|
|
84
|
+
status: 'ok',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
event: 'media_update',
|
|
88
|
+
call_id: ic.id,
|
|
89
|
+
status: 'ok',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
event: 'response',
|
|
93
|
+
call_id: oc.id,
|
|
94
|
+
method: 'INVITE',
|
|
95
|
+
msg: sip_msg({
|
|
96
|
+
$rs: '200',
|
|
97
|
+
$rr: 'OK',
|
|
98
|
+
'$(hdrcnt(v))': 1,
|
|
99
|
+
$fU: 'alice',
|
|
100
|
+
$fd: 'test.com',
|
|
101
|
+
$tU: 'bob',
|
|
102
|
+
'$hdr(content-type)': 'application/sdp',
|
|
103
|
+
$rb: '!{_}a=sendrecv',
|
|
104
|
+
'$hdr(X-MyHeader3)': 'ghi',
|
|
105
|
+
'$hdr(X-MyHeader4)': 'jkl',
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
], 1000)
|
|
109
|
+
|
|
110
|
+
await z.sleep(100)
|
|
111
|
+
|
|
112
|
+
sip.call.start_record_wav(oc.id, {file: './oc.wav'})
|
|
113
|
+
sip.call.start_record_wav(ic.id, {file: './ic.wav'})
|
|
114
|
+
|
|
115
|
+
sip.call.start_speech_recog(oc.id)
|
|
116
|
+
sip.call.start_speech_recog(ic.id)
|
|
117
|
+
|
|
118
|
+
await z.sleep(100)
|
|
119
|
+
|
|
120
|
+
sip.call.start_play_wav(oc.id, {file: 'samples/artifacts/hello_good_morning.wav', end_of_file_event: true, no_loop: true})
|
|
121
|
+
sip.call.start_play_wav(ic.id, {file: 'samples/artifacts/hello_good_morning.wav', end_of_file_event: true, no_loop: true})
|
|
122
|
+
|
|
123
|
+
await z.wait([
|
|
124
|
+
{
|
|
125
|
+
event: 'end_of_file',
|
|
126
|
+
call_id: ic.id,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
event: 'end_of_file',
|
|
130
|
+
call_id: oc.id,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
event: 'speech_transcript',
|
|
134
|
+
call_id: oc.id,
|
|
135
|
+
//transcript: 'hello good morning', // bad transcript (will not match)
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
event: 'speech_transcript',
|
|
139
|
+
call_id: ic.id,
|
|
140
|
+
//transcript: 'hello good morning', // bad transcript (will not match)
|
|
141
|
+
},
|
|
142
|
+
], 4000)
|
|
143
|
+
|
|
144
|
+
sip.call.stop_record_wav(oc.id)
|
|
145
|
+
sip.call.stop_record_wav(ic.id)
|
|
146
|
+
|
|
147
|
+
sip.call.terminate(oc.id)
|
|
148
|
+
|
|
149
|
+
await z.wait([
|
|
150
|
+
{
|
|
151
|
+
event: 'call_ended',
|
|
152
|
+
call_id: oc.id,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
event: 'call_ended',
|
|
156
|
+
call_id: ic.id,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
event: 'response',
|
|
160
|
+
call_id: oc.id,
|
|
161
|
+
method: 'BYE',
|
|
162
|
+
msg: sip_msg({
|
|
163
|
+
$rs: '200',
|
|
164
|
+
$rr: 'OK',
|
|
165
|
+
}),
|
|
166
|
+
},
|
|
167
|
+
], 1000)
|
|
168
|
+
|
|
169
|
+
await z.sleep(100)
|
|
170
|
+
|
|
171
|
+
console.log("Success")
|
|
172
|
+
|
|
173
|
+
sip.stop()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
test()
|
|
178
|
+
.catch(e => {
|
|
179
|
+
console.error(e)
|
|
180
|
+
process.exit(1)
|
|
181
|
+
})
|
|
182
|
+
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
var sip = require ('../index.js')
|
|
2
|
+
var Zeq = require('@mayama/zeq')
|
|
3
|
+
var z = new Zeq()
|
|
4
|
+
var m = require('data-matching')
|
|
5
|
+
var sip_msg = require('sip-matching')
|
|
6
|
+
var sdp = require('sdp-matching')
|
|
7
|
+
|
|
8
|
+
async function test() {
|
|
9
|
+
//sip.set_log_level(6)
|
|
10
|
+
sip.dtmf_aggregation_on(500)
|
|
11
|
+
|
|
12
|
+
sip.set_codecs("speex/16000/1:128")
|
|
13
|
+
|
|
14
|
+
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
15
|
+
var e = evt.args[0]
|
|
16
|
+
return e
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
console.log(sip.start((data) => { console.log(data)} ))
|
|
20
|
+
|
|
21
|
+
t1 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
|
|
22
|
+
t2 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
|
|
23
|
+
|
|
24
|
+
console.log("t1", t1)
|
|
25
|
+
console.log("t2", t2)
|
|
26
|
+
|
|
27
|
+
oc = sip.call.create(t1.id, {
|
|
28
|
+
from_uri: '"abc"<sip:alice@test.com>',
|
|
29
|
+
to_uri: `sip:bob@${t2.address}:${t2.port}`,
|
|
30
|
+
headers: {
|
|
31
|
+
'X-MyHeader1': 'abc',
|
|
32
|
+
'X-MyHeader2': 'def',
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
await z.wait([
|
|
37
|
+
{
|
|
38
|
+
event: "incoming_call",
|
|
39
|
+
call_id: m.collect("call_id"),
|
|
40
|
+
msg: sip_msg({
|
|
41
|
+
$rm: 'INVITE',
|
|
42
|
+
$fU: 'alice',
|
|
43
|
+
$fd: 'test.com',
|
|
44
|
+
$tU: 'bob',
|
|
45
|
+
'$hdr(X-MyHeader1)': 'abc',
|
|
46
|
+
'hdr_x_myheader2': 'def',
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
event: 'response',
|
|
51
|
+
call_id: oc.id,
|
|
52
|
+
method: 'INVITE',
|
|
53
|
+
msg: sip_msg({
|
|
54
|
+
$rs: '100',
|
|
55
|
+
$rr: 'Trying',
|
|
56
|
+
'$(hdrcnt(via))': 1,
|
|
57
|
+
'hdr_call_id': m.collect('sip_call_id'),
|
|
58
|
+
$fU: 'alice',
|
|
59
|
+
$fd: 'test.com',
|
|
60
|
+
$tU: 'bob',
|
|
61
|
+
'$hdr(l)': '0',
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
], 1000)
|
|
65
|
+
|
|
66
|
+
ic = {
|
|
67
|
+
id: z.store.call_id,
|
|
68
|
+
sip_call_id: z.store.sip_call_id,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
sip.call.respond(ic.id, {
|
|
72
|
+
code: 200,
|
|
73
|
+
reason:'OK',
|
|
74
|
+
headers: {
|
|
75
|
+
'X-MyHeader3': 'ghi',
|
|
76
|
+
'X-MyHeader4': 'jkl',
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
await z.wait([
|
|
81
|
+
{
|
|
82
|
+
event: 'media_update',
|
|
83
|
+
call_id: oc.id,
|
|
84
|
+
status: 'ok',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
event: 'media_update',
|
|
88
|
+
call_id: ic.id,
|
|
89
|
+
status: 'ok',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
event: 'response',
|
|
93
|
+
call_id: oc.id,
|
|
94
|
+
method: 'INVITE',
|
|
95
|
+
msg: sip_msg({
|
|
96
|
+
$rs: '200',
|
|
97
|
+
$rr: 'OK',
|
|
98
|
+
'$(hdrcnt(v))': 1,
|
|
99
|
+
$fU: 'alice',
|
|
100
|
+
$fd: 'test.com',
|
|
101
|
+
$tU: 'bob',
|
|
102
|
+
'$hdr(content-type)': 'application/sdp',
|
|
103
|
+
$rb: '!{_}a=sendrecv',
|
|
104
|
+
'$hdr(X-MyHeader3)': 'ghi',
|
|
105
|
+
'$hdr(X-MyHeader4)': 'jkl',
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
], 1000)
|
|
109
|
+
|
|
110
|
+
await z.sleep(100)
|
|
111
|
+
|
|
112
|
+
sip.call.start_record_wav(oc.id, {file: './oc.wav'})
|
|
113
|
+
sip.call.start_record_wav(ic.id, {file: './ic.wav'})
|
|
114
|
+
|
|
115
|
+
sip.call.start_speech_recog(oc.id)
|
|
116
|
+
sip.call.start_speech_recog(ic.id)
|
|
117
|
+
|
|
118
|
+
await z.sleep(100)
|
|
119
|
+
|
|
120
|
+
sip.call.start_speech_synth(oc.id, {voice: 'kal16', text: 'Good morning.', end_of_speech_event: true, no_loop: true})
|
|
121
|
+
sip.call.start_speech_synth(ic.id, {voice: 'kal16', text: 'How are you?', end_of_speech_event: true, no_loop: true})
|
|
122
|
+
|
|
123
|
+
await z.wait([
|
|
124
|
+
{
|
|
125
|
+
event: 'end_of_speech',
|
|
126
|
+
call_id: ic.id,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
event: 'end_of_speech',
|
|
130
|
+
call_id: oc.id,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
event: 'speech_transcript',
|
|
134
|
+
call_id: oc.id,
|
|
135
|
+
transcript: 'how are you',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
event: 'speech_transcript',
|
|
139
|
+
call_id: ic.id,
|
|
140
|
+
transcript: 'good morning',
|
|
141
|
+
},
|
|
142
|
+
], 3000)
|
|
143
|
+
|
|
144
|
+
sip.call.stop_speech_synth(oc.id) // this is not actually necessary. It is used just to confirm the command works
|
|
145
|
+
sip.call.stop_speech_synth(ic.id) // this is not actually necessary. It is used just to confirm the command works
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
sip.call.stop_record_wav(oc.id)
|
|
149
|
+
sip.call.stop_record_wav(ic.id)
|
|
150
|
+
|
|
151
|
+
sip.call.terminate(oc.id)
|
|
152
|
+
|
|
153
|
+
await z.wait([
|
|
154
|
+
{
|
|
155
|
+
event: 'call_ended',
|
|
156
|
+
call_id: oc.id,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
event: 'call_ended',
|
|
160
|
+
call_id: ic.id,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
event: 'response',
|
|
164
|
+
call_id: oc.id,
|
|
165
|
+
method: 'BYE',
|
|
166
|
+
msg: sip_msg({
|
|
167
|
+
$rs: '200',
|
|
168
|
+
$rr: 'OK',
|
|
169
|
+
}),
|
|
170
|
+
},
|
|
171
|
+
], 1000)
|
|
172
|
+
|
|
173
|
+
await z.sleep(100)
|
|
174
|
+
|
|
175
|
+
console.log("Success")
|
|
176
|
+
|
|
177
|
+
sip.stop()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
test()
|
|
182
|
+
.catch(e => {
|
|
183
|
+
console.error(e)
|
|
184
|
+
process.exit(1)
|
|
185
|
+
})
|
|
186
|
+
|