presidium 0.15.31 → 0.15.32
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/TranscribeStream.js +6 -1
- package/TranscribeStream.test.js +9 -2
- package/package.json +1 -1
package/TranscribeStream.js
CHANGED
|
@@ -115,7 +115,12 @@ const TranscribeStream = function (options) {
|
|
|
115
115
|
})
|
|
116
116
|
this.websocket.on('message', chunk => {
|
|
117
117
|
const { headers, body } = unmarshalMessage(chunk)
|
|
118
|
-
if (
|
|
118
|
+
if (headers[':message-type'] == 'exception') {
|
|
119
|
+
const error = new Error(body.Message)
|
|
120
|
+
error.name = headers[':exception-type']
|
|
121
|
+
this.emit('error', error)
|
|
122
|
+
}
|
|
123
|
+
else if (body.Transcript.Results.length > 0) {
|
|
119
124
|
if (body.Transcript.Results[0].IsPartial) {
|
|
120
125
|
this.emit('partialTranscription', body.Transcript.Results[0])
|
|
121
126
|
} else {
|
package/TranscribeStream.test.js
CHANGED
|
@@ -52,8 +52,6 @@ const test = new Test('TranscribeStream', async function () {
|
|
|
52
52
|
wav.fromScratch(1, 8000, '8', Buffer.from(event.media.payload, 'base64'))
|
|
53
53
|
wav.fromMuLaw()
|
|
54
54
|
testTranscribeStream.sendAudioChunk(Buffer.from(wav.data.samples))
|
|
55
|
-
} else if (event.event == 'stop') {
|
|
56
|
-
testTranscribeStream.close()
|
|
57
55
|
}
|
|
58
56
|
})
|
|
59
57
|
|
|
@@ -64,6 +62,15 @@ const test = new Test('TranscribeStream', async function () {
|
|
|
64
62
|
})
|
|
65
63
|
assert.equal(testTranscription, 'Hello, world.')
|
|
66
64
|
|
|
65
|
+
// wait for timeout error to test error handling
|
|
66
|
+
await new Promise(resolve => {
|
|
67
|
+
testTranscribeStream.on('error', error => {
|
|
68
|
+
console.error(error)
|
|
69
|
+
testTranscribeStream.close()
|
|
70
|
+
resolve()
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
67
74
|
/*
|
|
68
75
|
// fill media-stream-fixture-aws-keynote.txt
|
|
69
76
|
const Twilio = require('@claimyr_hq/twilio/Twilio')
|