@memori.ai/memori-api-client 0.10.3 → 1.0.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.
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
7
  var fetch$1 = _interopDefault(require('cross-fetch'));
8
- var speechSdk = require('microsoft-cognitiveservices-speech-sdk');
9
8
 
10
9
  function _regeneratorRuntime() {
11
10
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -1227,14 +1226,16 @@ var correlationPairs = (function (apiUrl) {
1227
1226
  /**
1228
1227
  * Lists all Correlation Pair objects.
1229
1228
  * @param {string} sessionId The session ID
1229
+ * @param {number=} from The starting index
1230
+ * @param {number=} howMany The number of items to return
1230
1231
  */
1231
1232
  getCorrelationPairs: function () {
1232
- var _getCorrelationPairs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId) {
1233
+ var _getCorrelationPairs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId, from, howMany) {
1233
1234
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1234
1235
  while (1) {
1235
1236
  switch (_context.prev = _context.next) {
1236
1237
  case 0:
1237
- return _context.abrupt("return", apiFetcher("/CorrelationPairs/" + sessionId, {
1238
+ return _context.abrupt("return", apiFetcher("/CorrelationPairs/" + sessionId + (from ? "/" + from + (howMany ? "/" + howMany : '') : ''), {
1238
1239
  method: 'GET',
1239
1240
  apiUrl: apiUrl
1240
1241
  }));
@@ -1247,7 +1248,7 @@ var correlationPairs = (function (apiUrl) {
1247
1248
  }, _callee);
1248
1249
  }));
1249
1250
 
1250
- function getCorrelationPairs(_x) {
1251
+ function getCorrelationPairs(_x, _x2, _x3) {
1251
1252
  return _getCorrelationPairs.apply(this, arguments);
1252
1253
  }
1253
1254
 
@@ -1255,19 +1256,20 @@ var correlationPairs = (function (apiUrl) {
1255
1256
  }(),
1256
1257
 
1257
1258
  /**
1258
- * Removes an existing Correlation Pair object.
1259
+ * Adds a new Correlation Pair object.
1259
1260
  * @param {string} sessionId The session ID
1260
- * @param {string} pairId The Correlation Pair object ID
1261
+ * @param {CorrelationPair} correlationPair The Correlation Pair object
1261
1262
  */
1262
- deleteCorrelationPair: function () {
1263
- var _deleteCorrelationPair = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, pairId) {
1263
+ postCorrelationPair: function () {
1264
+ var _postCorrelationPair = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, correlationPair) {
1264
1265
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1265
1266
  while (1) {
1266
1267
  switch (_context2.prev = _context2.next) {
1267
1268
  case 0:
1268
- return _context2.abrupt("return", apiFetcher("/CorrelationPair/" + sessionId + "/" + pairId, {
1269
- method: 'GET',
1270
- apiUrl: apiUrl
1269
+ return _context2.abrupt("return", apiFetcher("/CorrelationPair/" + sessionId, {
1270
+ method: 'POST',
1271
+ apiUrl: apiUrl,
1272
+ body: correlationPair
1271
1273
  }));
1272
1274
 
1273
1275
  case 1:
@@ -1278,7 +1280,38 @@ var correlationPairs = (function (apiUrl) {
1278
1280
  }, _callee2);
1279
1281
  }));
1280
1282
 
1281
- function deleteCorrelationPair(_x2, _x3) {
1283
+ function postCorrelationPair(_x4, _x5) {
1284
+ return _postCorrelationPair.apply(this, arguments);
1285
+ }
1286
+
1287
+ return postCorrelationPair;
1288
+ }(),
1289
+
1290
+ /**
1291
+ * Removes an existing Correlation Pair object.
1292
+ * @param {string} sessionId The session ID
1293
+ * @param {string} pairId The Correlation Pair object ID
1294
+ */
1295
+ deleteCorrelationPair: function () {
1296
+ var _deleteCorrelationPair = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, pairId) {
1297
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1298
+ while (1) {
1299
+ switch (_context3.prev = _context3.next) {
1300
+ case 0:
1301
+ return _context3.abrupt("return", apiFetcher("/CorrelationPair/" + sessionId + "/" + pairId, {
1302
+ method: 'DELETE',
1303
+ apiUrl: apiUrl
1304
+ }));
1305
+
1306
+ case 1:
1307
+ case "end":
1308
+ return _context3.stop();
1309
+ }
1310
+ }
1311
+ }, _callee3);
1312
+ }));
1313
+
1314
+ function deleteCorrelationPair(_x6, _x7) {
1282
1315
  return _deleteCorrelationPair.apply(this, arguments);
1283
1316
  }
1284
1317
 
@@ -2358,14 +2391,15 @@ var memories = (function (apiUrl) {
2358
2391
  /**
2359
2392
  * Lists all Memory objects.
2360
2393
  * @param {string} sessionId The session ID
2394
+ * @param {string=} type Optional type of the Memory objects to list: ALL, CONTENTS, DEFAULTS, DRAFTS
2361
2395
  */
2362
2396
  getMemories: function () {
2363
- var _getMemories = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId) {
2397
+ var _getMemories = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId, type) {
2364
2398
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2365
2399
  while (1) {
2366
2400
  switch (_context.prev = _context.next) {
2367
2401
  case 0:
2368
- return _context.abrupt("return", apiFetcher("/Memories/" + sessionId, {
2402
+ return _context.abrupt("return", apiFetcher("/Memories/" + sessionId + (type ? "/" + type : ''), {
2369
2403
  method: 'GET',
2370
2404
  apiUrl: apiUrl
2371
2405
  }));
@@ -2378,7 +2412,7 @@ var memories = (function (apiUrl) {
2378
2412
  }, _callee);
2379
2413
  }));
2380
2414
 
2381
- function getMemories(_x) {
2415
+ function getMemories(_x, _x2) {
2382
2416
  return _getMemories.apply(this, arguments);
2383
2417
  }
2384
2418
 
@@ -2390,7 +2424,7 @@ var memories = (function (apiUrl) {
2390
2424
  * @param {string} sessionId The session ID
2391
2425
  * @param {number} from The starting index
2392
2426
  * @param {number} howMany The number of items to return
2393
- * @param {string=} type Optional type of the Memory objects to list: ALL, CONTENTS, DEFAULTS
2427
+ * @param {string=} type Optional type of the Memory objects to list: ALL, CONTENTS, DEFAULTS, DRAFTS
2394
2428
  */
2395
2429
  getMemoriesPaginated: function () {
2396
2430
  var _getMemoriesPaginated = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, from, howMany, type) {
@@ -2411,7 +2445,7 @@ var memories = (function (apiUrl) {
2411
2445
  }, _callee2);
2412
2446
  }));
2413
2447
 
2414
- function getMemoriesPaginated(_x2, _x3, _x4, _x5) {
2448
+ function getMemoriesPaginated(_x3, _x4, _x5, _x6) {
2415
2449
  return _getMemoriesPaginated.apply(this, arguments);
2416
2450
  }
2417
2451
 
@@ -2442,7 +2476,7 @@ var memories = (function (apiUrl) {
2442
2476
  }, _callee3);
2443
2477
  }));
2444
2478
 
2445
- function getMemory(_x6, _x7) {
2479
+ function getMemory(_x7, _x8) {
2446
2480
  return _getMemory.apply(this, arguments);
2447
2481
  }
2448
2482
 
@@ -2474,7 +2508,7 @@ var memories = (function (apiUrl) {
2474
2508
  }, _callee4);
2475
2509
  }));
2476
2510
 
2477
- function patchMemory(_x8, _x9) {
2511
+ function patchMemory(_x9, _x10) {
2478
2512
  return _patchMemory.apply(this, arguments);
2479
2513
  }
2480
2514
 
@@ -2505,7 +2539,7 @@ var memories = (function (apiUrl) {
2505
2539
  }, _callee5);
2506
2540
  }));
2507
2541
 
2508
- function deleteMemory(_x10, _x11) {
2542
+ function deleteMemory(_x11, _x12) {
2509
2543
  return _deleteMemory.apply(this, arguments);
2510
2544
  }
2511
2545
 
@@ -2537,7 +2571,7 @@ var memories = (function (apiUrl) {
2537
2571
  }, _callee6);
2538
2572
  }));
2539
2573
 
2540
- function postMemory(_x12, _x13) {
2574
+ function postMemory(_x13, _x14) {
2541
2575
  return _postMemory.apply(this, arguments);
2542
2576
  }
2543
2577
 
@@ -2568,7 +2602,7 @@ var memories = (function (apiUrl) {
2568
2602
  }, _callee7);
2569
2603
  }));
2570
2604
 
2571
- function getMemoryAccess(_x14, _x15) {
2605
+ function getMemoryAccess(_x15, _x16) {
2572
2606
  return _getMemoryAccess.apply(this, arguments);
2573
2607
  }
2574
2608
 
@@ -3557,31 +3591,63 @@ var unansweredQuestions = (function (apiUrl) {
3557
3591
  return getUnansweredQuestionsPaginated;
3558
3592
  }(),
3559
3593
 
3594
+ /**
3595
+ * Adds a new Unanswered Question object.
3596
+ * @param {string} sessionId The session ID
3597
+ * @param {UnansweredQuestion} unansweredQuestion The Unanswered Question object
3598
+ */
3599
+ postUnansweredQuestion: function () {
3600
+ var _postUnansweredQuestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, unansweredQuestion) {
3601
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3602
+ while (1) {
3603
+ switch (_context3.prev = _context3.next) {
3604
+ case 0:
3605
+ return _context3.abrupt("return", apiFetcher("/UnansweredQuestion/" + sessionId, {
3606
+ method: 'POST',
3607
+ apiUrl: apiUrl,
3608
+ body: unansweredQuestion
3609
+ }));
3610
+
3611
+ case 1:
3612
+ case "end":
3613
+ return _context3.stop();
3614
+ }
3615
+ }
3616
+ }, _callee3);
3617
+ }));
3618
+
3619
+ function postUnansweredQuestion(_x5, _x6) {
3620
+ return _postUnansweredQuestion.apply(this, arguments);
3621
+ }
3622
+
3623
+ return postUnansweredQuestion;
3624
+ }(),
3625
+
3560
3626
  /**
3561
3627
  * Removes an existing Unanswered Question object.
3562
3628
  * @param {string} sessionId The session ID
3563
3629
  * @param {string} unansweredQuestionId The Unanswered Question object ID
3564
3630
  */
3565
3631
  deleteUnansweredQuestion: function () {
3566
- var _deleteUnansweredQuestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, unansweredQuestionId) {
3567
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3632
+ var _deleteUnansweredQuestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(sessionId, unansweredQuestionId) {
3633
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3568
3634
  while (1) {
3569
- switch (_context3.prev = _context3.next) {
3635
+ switch (_context4.prev = _context4.next) {
3570
3636
  case 0:
3571
- return _context3.abrupt("return", apiFetcher("/UnansweredQuestion/" + sessionId + "/" + unansweredQuestionId, {
3637
+ return _context4.abrupt("return", apiFetcher("/UnansweredQuestion/" + sessionId + "/" + unansweredQuestionId, {
3572
3638
  method: 'DELETE',
3573
3639
  apiUrl: apiUrl
3574
3640
  }));
3575
3641
 
3576
3642
  case 1:
3577
3643
  case "end":
3578
- return _context3.stop();
3644
+ return _context4.stop();
3579
3645
  }
3580
3646
  }
3581
- }, _callee3);
3647
+ }, _callee4);
3582
3648
  }));
3583
3649
 
3584
- function deleteUnansweredQuestion(_x5, _x6) {
3650
+ function deleteUnansweredQuestion(_x7, _x8) {
3585
3651
  return _deleteUnansweredQuestion.apply(this, arguments);
3586
3652
  }
3587
3653
 
@@ -3898,6 +3964,37 @@ var chatLogs = (function (apiUrl) {
3898
3964
  return getChatLogs;
3899
3965
  }(),
3900
3966
 
3967
+ /**
3968
+ * Gets the Chat Log objects for the Memori of the current session recorded during a specific other session.
3969
+ * @param {string} sessionId The session ID
3970
+ * @param {string} chatLogSessionID The session ID for which Chat Log objects are being searched
3971
+ */
3972
+ getSessionChatLogs: function () {
3973
+ var _getSessionChatLogs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, chatLogSessionID) {
3974
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3975
+ while (1) {
3976
+ switch (_context2.prev = _context2.next) {
3977
+ case 0:
3978
+ return _context2.abrupt("return", apiFetcher("/SessionChatLogs/" + sessionId + "/" + chatLogSessionID, {
3979
+ method: 'GET',
3980
+ apiUrl: apiUrl
3981
+ }));
3982
+
3983
+ case 1:
3984
+ case "end":
3985
+ return _context2.stop();
3986
+ }
3987
+ }
3988
+ }, _callee2);
3989
+ }));
3990
+
3991
+ function getSessionChatLogs(_x4, _x5) {
3992
+ return _getSessionChatLogs.apply(this, arguments);
3993
+ }
3994
+
3995
+ return getSessionChatLogs;
3996
+ }(),
3997
+
3901
3998
  /**
3902
3999
  * Removes all Chat Log objects in a specific date internval.
3903
4000
  * @param {string} sessionId The session ID
@@ -3905,25 +4002,25 @@ var chatLogs = (function (apiUrl) {
3905
4002
  * @param {?string} dateTo The optional end of the date interval, in UTC time, in the format yyyyMMddHHmmssfff
3906
4003
  */
3907
4004
  deleteChatLogs: function () {
3908
- var _deleteChatLogs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, dateFrom, dateTo) {
3909
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4005
+ var _deleteChatLogs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, dateFrom, dateTo) {
4006
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3910
4007
  while (1) {
3911
- switch (_context2.prev = _context2.next) {
4008
+ switch (_context3.prev = _context3.next) {
3912
4009
  case 0:
3913
- return _context2.abrupt("return", apiFetcher("/ChatLogs/" + sessionId + (dateFrom ? "/" + dateFrom : '') + (dateFrom && dateTo ? "/" + dateTo : ''), {
4010
+ return _context3.abrupt("return", apiFetcher("/ChatLogs/" + sessionId + (dateFrom ? "/" + dateFrom : '') + (dateFrom && dateTo ? "/" + dateTo : ''), {
3914
4011
  method: 'DELETE',
3915
4012
  apiUrl: apiUrl
3916
4013
  }));
3917
4014
 
3918
4015
  case 1:
3919
4016
  case "end":
3920
- return _context2.stop();
4017
+ return _context3.stop();
3921
4018
  }
3922
4019
  }
3923
- }, _callee2);
4020
+ }, _callee3);
3924
4021
  }));
3925
4022
 
3926
- function deleteChatLogs(_x4, _x5, _x6) {
4023
+ function deleteChatLogs(_x6, _x7, _x8) {
3927
4024
  return _deleteChatLogs.apply(this, arguments);
3928
4025
  }
3929
4026
 
@@ -3936,25 +4033,25 @@ var chatLogs = (function (apiUrl) {
3936
4033
  * @param {string} chatLogId The Chat Log object ID
3937
4034
  */
3938
4035
  deleteChatLog: function () {
3939
- var _deleteChatLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, chatLogId) {
3940
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4036
+ var _deleteChatLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(sessionId, chatLogId) {
4037
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3941
4038
  while (1) {
3942
- switch (_context3.prev = _context3.next) {
4039
+ switch (_context4.prev = _context4.next) {
3943
4040
  case 0:
3944
- return _context3.abrupt("return", apiFetcher("/ChatLog/" + sessionId + "/" + chatLogId, {
4041
+ return _context4.abrupt("return", apiFetcher("/ChatLog/" + sessionId + "/" + chatLogId, {
3945
4042
  method: 'DELETE',
3946
4043
  apiUrl: apiUrl
3947
4044
  }));
3948
4045
 
3949
4046
  case 1:
3950
4047
  case "end":
3951
- return _context3.stop();
4048
+ return _context4.stop();
3952
4049
  }
3953
4050
  }
3954
- }, _callee3);
4051
+ }, _callee4);
3955
4052
  }));
3956
4053
 
3957
- function deleteChatLog(_x7, _x8) {
4054
+ function deleteChatLog(_x9, _x10) {
3958
4055
  return _deleteChatLog.apply(this, arguments);
3959
4056
  }
3960
4057
 
@@ -4010,239 +4107,6 @@ var constants = {
4010
4107
  anonTag: anonTag
4011
4108
  };
4012
4109
 
4013
- var getTTSVoice = function getTTSVoice(lang, voiceType) {
4014
- var voice = '';
4015
- var voiceLang = lang.toUpperCase();
4016
-
4017
- switch (voiceLang) {
4018
- case 'IT':
4019
- voice = "" + (voiceType === 'MALE' ? 'it-IT-DiegoNeural' : 'it-IT-ElsaNeural');
4020
- break;
4021
-
4022
- case 'DE':
4023
- voice = "" + (voiceType === 'MALE' ? 'de-DE-ConradNeural' : 'de-DE-KatjaNeural');
4024
- break;
4025
-
4026
- case 'EN':
4027
- voice = "" + (voiceType === 'MALE' ? 'en-GB-RyanNeural' : 'en-GB-SoniaNeural');
4028
- break;
4029
-
4030
- case 'ES':
4031
- voice = "" + (voiceType === 'MALE' ? 'es-ES-AlvaroNeural' : 'es-ES-ElviraNeural');
4032
- break;
4033
-
4034
- case 'FR':
4035
- voice = "" + (voiceType === 'MALE' ? 'fr-FR-HenriNeural' : 'fr-FR-DeniseNeural');
4036
- break;
4037
-
4038
- case 'PT':
4039
- voice = "" + (voiceType === 'MALE' ? 'pt-PT-DuarteNeural' : 'pt-PT-RaquelNeural');
4040
- break;
4041
-
4042
- default:
4043
- voice = "" + (voiceType === 'MALE' ? 'it-IT-DiegoNeural' : 'it-IT-IsabellaNeural');
4044
- break;
4045
- }
4046
-
4047
- return voice;
4048
- };
4049
-
4050
- var getCultureCodeByLanguage = function getCultureCodeByLanguage(lang) {
4051
- var voice = '';
4052
- var voiceLang = lang.toUpperCase();
4053
-
4054
- switch (voiceLang) {
4055
- case 'IT':
4056
- voice = 'it-IT';
4057
- break;
4058
-
4059
- case 'DE':
4060
- voice = 'de-DE';
4061
- break;
4062
-
4063
- case 'EN':
4064
- voice = 'en-US';
4065
- break;
4066
-
4067
- case 'ES':
4068
- voice = 'es-ES';
4069
- break;
4070
-
4071
- case 'FR':
4072
- voice = 'fr-FR';
4073
- break;
4074
-
4075
- case 'PT':
4076
- voice = 'pt-PT';
4077
- break;
4078
-
4079
- default:
4080
- voice = 'it-IT';
4081
- break;
4082
- }
4083
-
4084
- return voice;
4085
- };
4086
- /**
4087
- * EXPERIMENTAL
4088
- */
4089
-
4090
-
4091
- var speech = function speech(AZURE_COGNITIVE_SERVICES_TTS_KEY, DEBUG) {
4092
- if (DEBUG === void 0) {
4093
- DEBUG = false;
4094
- }
4095
-
4096
- return function (lang, voiceType) {
4097
- var speechConfig = speechSdk.SpeechConfig.fromSubscription(AZURE_COGNITIVE_SERVICES_TTS_KEY, 'eastus');
4098
- var speechSynthesizer;
4099
- var audioDestination;
4100
- audioDestination = new speechSdk.SpeakerAudioDestination();
4101
- var audioOutputConfig = speechSdk.AudioConfig.fromSpeakerOutput(audioDestination); // https://docs.microsoft.com/it-it/azure/cognitive-services/speech-service/language-support#text-to-speech
4102
-
4103
- speechConfig.speechSynthesisVoiceName = getTTSVoice(lang, voiceType);
4104
- var langCultureCode = getCultureCodeByLanguage(lang);
4105
- speechConfig.speechSynthesisLanguage = langCultureCode;
4106
- speechConfig.speechRecognitionLanguage = langCultureCode;
4107
- /**
4108
- * speak
4109
- * @description Speaks the text using the speech synthesizer. (TTS)
4110
- * @param {string} text - The text to be synthesized.
4111
- * @param {func=} onAudioEnd - The callback to be invoked when the synthesized audio is finished.
4112
- */
4113
-
4114
- var speak = function speak(text, onAudioEnd) {
4115
- stopSpeaking();
4116
- speechSynthesizer = new speechSdk.SpeechSynthesizer(speechConfig, audioOutputConfig);
4117
- if (onAudioEnd) audioDestination.onAudioEnd = onAudioEnd;
4118
- speechSynthesizer.speakTextAsync(text, function (result) {
4119
- if (result) {
4120
- try {
4121
- if (DEBUG) console.log('speak result', result);
4122
-
4123
- if (speechSynthesizer) {
4124
- speechSynthesizer.close();
4125
- speechSynthesizer = null;
4126
- }
4127
- } catch (e) {
4128
- console.error('speak error: ', e);
4129
- window.speechSynthesis.speak(new SpeechSynthesisUtterance(text));
4130
- }
4131
- } else if (DEBUG) {
4132
- console.log('speak no result', result);
4133
- }
4134
- }, function (error) {
4135
- console.error('speak:', error);
4136
- window.speechSynthesis.speak(new SpeechSynthesisUtterance(text));
4137
- });
4138
- };
4139
- /**
4140
- * isSpeaking
4141
- * @description Returns true if the synthesizer is speaking.
4142
- * @returns {boolean}
4143
- */
4144
-
4145
-
4146
- var isSpeaking = function isSpeaking() {
4147
- return !!speechSynthesizer;
4148
- };
4149
- /**
4150
- * stopSpeaking
4151
- * @description Stops the speech synthesizer if it is synthesizing.
4152
- */
4153
-
4154
-
4155
- var stopSpeaking = function stopSpeaking() {
4156
- if (audioDestination) audioDestination.pause();
4157
-
4158
- if (speechSynthesizer) {
4159
- speechSynthesizer.close();
4160
- speechSynthesizer = null;
4161
- }
4162
- };
4163
-
4164
- var audioInputConfig = speechSdk.AudioConfig.fromDefaultMicrophoneInput();
4165
- var recognizer;
4166
- /**
4167
- * recognize
4168
- * @description Starts the speech recognition.
4169
- * @param {func=} onRecognized - Callback method invoked when the speech is recognized with the text.
4170
- */
4171
-
4172
- var recognize = function recognize(onRecognized) {
4173
- recognizer = new speechSdk.SpeechRecognizer(speechConfig, audioInputConfig);
4174
-
4175
- recognizer.recognizing = function (_s, e) {
4176
- if (DEBUG) console.log("RECOGNIZING: Text=" + e.result.text);
4177
- };
4178
-
4179
- recognizer.recognized = function (_s, e) {
4180
- if (e.result.reason === speechSdk.ResultReason.RecognizedSpeech) {
4181
- var _e$result$text;
4182
-
4183
- if (DEBUG) console.log("RECOGNIZED: Text=" + e.result.text);
4184
- onRecognized((_e$result$text = e.result.text) != null ? _e$result$text : '');
4185
- } else if (e.result.reason === speechSdk.ResultReason.NoMatch && DEBUG) {
4186
- console.log('NOMATCH: Speech could not be recognized.');
4187
- }
4188
- };
4189
-
4190
- recognizer.canceled = function (_s, e) {
4191
- if (DEBUG) console.log("CANCELED: Reason=" + e.reason);
4192
-
4193
- if (e.reason === speechSdk.CancellationReason.Error && DEBUG) {
4194
- console.log("\"CANCELED: ErrorCode=" + e.errorCode);
4195
- console.log("\"CANCELED: ErrorDetails=" + e.errorDetails);
4196
- console.log('CANCELED: Did you set the speech resource key and region values?');
4197
- }
4198
-
4199
- stopRecognizing();
4200
- };
4201
-
4202
- recognizer.sessionStopped = function (_s, _e) {
4203
- if (DEBUG) console.log('\n Session stopped event.');
4204
- if (recognizer) recognizer.stopContinuousRecognitionAsync();
4205
- };
4206
-
4207
- recognizer.startContinuousRecognitionAsync();
4208
- };
4209
- /**
4210
- * isRecognizing
4211
- * @description Returns true if the recognizer is recognizing.
4212
- * @returns {boolean}
4213
- */
4214
-
4215
-
4216
- var isRecognizing = function isRecognizing() {
4217
- return !!recognizer;
4218
- };
4219
- /**
4220
- * stopRecognizing
4221
- * @description Stops the speech recognizer if it is recognizing.
4222
- * @param {func=} onStop - (optional) The callback to be invoked when the speech recognition is stopped.
4223
- */
4224
-
4225
-
4226
- var stopRecognizing = function stopRecognizing(onStop) {
4227
- if (recognizer) {
4228
- recognizer.stopContinuousRecognitionAsync();
4229
- recognizer.close();
4230
- recognizer = null;
4231
- if (onStop) onStop();
4232
- }
4233
- };
4234
-
4235
- return {
4236
- speak: speak,
4237
- isSpeaking: isSpeaking,
4238
- stopSpeaking: stopSpeaking,
4239
- recognize: recognize,
4240
- isRecognizing: isRecognizing,
4241
- stopRecognizing: stopRecognizing
4242
- };
4243
- };
4244
- };
4245
-
4246
4110
  var asset$1 = (function (apiUrl) {
4247
4111
  return {
4248
4112
  /**
@@ -4285,7 +4149,6 @@ var api = function api(hostname) {
4285
4149
  return _extends({
4286
4150
  backend: backendAPI(apiUrl + "/api/v2")
4287
4151
  }, engine(apiUrl + "/memori/v2"), {
4288
- speech: speech,
4289
4152
  constants: constants,
4290
4153
  asset: asset$1(apiUrl + "/api/v2")
4291
4154
  });