@fonoster/voice 0.3.6-alpha.14 → 0.3.6-alpha.17

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.
@@ -24,7 +24,10 @@ class GatherVerb extends verb_1.Verb {
24
24
  // assertsValuesIsZeroOrGreater("timeout", options.timeout);
25
25
  (0, asserts_1.assertsValueIsPositive)("numDigits", options.numDigits);
26
26
  (0, asserts_1.assertsFinishOnKeyIsChar)(options.finishOnKey);
27
- options.timeout = !options.timeout && options.source.includes("speech") ? 10000 : options.timeout || 4000;
27
+ options.timeout =
28
+ !options.timeout && options.source.includes("speech")
29
+ ? 10000
30
+ : options.timeout || 4000;
28
31
  return new Promise(async (resolve, reject) => {
29
32
  logger_1.default.verbose(`@fonoster/voice started gather [source = ${options.source}]`);
30
33
  if (options.source.includes("dtmf")) {
@@ -37,27 +37,29 @@ const waitForSpeech = async (sessionId, options, verb, speechProvider) => new Pr
37
37
  token = pubsub_js_1.default.subscribe(`ReceivingMedia.${sessionId}`, (type, data) => {
38
38
  readable.push(data);
39
39
  });
40
+ await (0, utils_1.startMediaTransfer)(verb, sessionId);
41
+ let enabledMedia = true;
42
+ if (options.timeout > 0) {
43
+ timer = setTimeout(() => {
44
+ if (enabledMedia)
45
+ (0, utils_1.stopMediaTransfer)(verb, sessionId);
46
+ pubsub_js_1.default.unsubscribe(token);
47
+ speechTracker.client.close();
48
+ resolve("");
49
+ enabledMedia = false;
50
+ }, options.timeout);
51
+ }
40
52
  speechTracker
41
53
  .transcribe(readable)
42
- .then((result) => {
54
+ .then((result) => resolve(result.transcript))
55
+ .catch(reject)
56
+ .finally(() => {
57
+ if (enabledMedia)
58
+ (0, utils_1.stopMediaTransfer)(verb, sessionId);
43
59
  if (timer)
44
60
  clearTimeout(timer);
45
- resolve(result.transcript);
46
- })
47
- .catch(reject)
48
- .finally(async () => {
49
61
  pubsub_js_1.default.unsubscribe(token);
50
- await (0, utils_1.stopMediaTransfer)(verb, sessionId);
62
+ enabledMedia = false;
51
63
  });
52
- await (0, utils_1.startMediaTransfer)(verb, sessionId);
53
- if (options.timeout > 0) {
54
- timer = setTimeout(async () => {
55
- // Simply resolve an empty string
56
- resolve("");
57
- pubsub_js_1.default.unsubscribe(token);
58
- await (0, utils_1.stopMediaTransfer)(verb, sessionId);
59
- return;
60
- }, options.timeout);
61
- }
62
64
  });
63
65
  exports.default = waitForSpeech;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/voice",
3
- "version": "0.3.6-alpha.14",
3
+ "version": "0.3.6-alpha.17",
4
4
  "description": "Voice verbs",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -29,18 +29,17 @@
29
29
  "url": "https://github.com/fonoster/fonoster/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@fonoster/common": "^0.3.6-alpha.14",
33
- "@fonoster/logger": "^0.3.6-alpha.14",
32
+ "@fonoster/common": "^0.3.6-alpha.17",
33
+ "@fonoster/logger": "^0.3.6-alpha.17",
34
34
  "@opentelemetry/api": "^1.0.2",
35
35
  "@opentelemetry/node": "^0.24.0",
36
36
  "@opentelemetry/plugin-express": "^0.15.0",
37
37
  "@opentelemetry/plugin-http": "^0.18.2",
38
38
  "@opentelemetry/plugin-https": "^0.18.2",
39
- "@opentelemetry/resources": "0.25.0",
40
- "@opentelemetry/sdk-metrics-base": "0.25.0",
41
- "@opentelemetry/sdk-trace-base": "0.25.0",
42
- "@opentelemetry/semantic-conventions": "0.25.0",
43
- "@opentelemetry/tracing": "^0.24.0",
39
+ "@opentelemetry/resources": "^1.0.1",
40
+ "@opentelemetry/sdk-metrics-base": "0.27.0",
41
+ "@opentelemetry/sdk-trace-base": "^1.0.1",
42
+ "@opentelemetry/semantic-conventions": "^1.0.1",
44
43
  "bson-objectid": "^2.0.2",
45
44
  "deepmerge": "^4.2.2",
46
45
  "express": "^4.17.1",
@@ -48,7 +47,7 @@
48
47
  "pubsub-js": "^1.9.3",
49
48
  "sync": "^0.2.5"
50
49
  },
51
- "gitHead": "26503d8c745e5917e7de9516485ae3bab1265c72",
50
+ "gitHead": "51bb272007482ab534931443cdab9e4285c2335a",
52
51
  "devDependencies": {
53
52
  "@types/pubsub-js": "^1.8.2"
54
53
  }