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.
@@ -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 (body.Transcript.Results.length > 0) {
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 {
@@ -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')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "0.15.31",
3
+ "version": "0.15.32",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",