@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.
@@ -1,5 +1,4 @@
1
1
  import fetch$1 from 'cross-fetch';
2
- import { SpeechConfig, SpeakerAudioDestination, AudioConfig, SpeechSynthesizer, SpeechRecognizer, ResultReason, CancellationReason } from 'microsoft-cognitiveservices-speech-sdk';
3
2
 
4
3
  function _regeneratorRuntime() {
5
4
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -1221,14 +1220,16 @@ var correlationPairs = (function (apiUrl) {
1221
1220
  /**
1222
1221
  * Lists all Correlation Pair objects.
1223
1222
  * @param {string} sessionId The session ID
1223
+ * @param {number=} from The starting index
1224
+ * @param {number=} howMany The number of items to return
1224
1225
  */
1225
1226
  getCorrelationPairs: function () {
1226
- var _getCorrelationPairs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId) {
1227
+ var _getCorrelationPairs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId, from, howMany) {
1227
1228
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1228
1229
  while (1) {
1229
1230
  switch (_context.prev = _context.next) {
1230
1231
  case 0:
1231
- return _context.abrupt("return", apiFetcher("/CorrelationPairs/" + sessionId, {
1232
+ return _context.abrupt("return", apiFetcher("/CorrelationPairs/" + sessionId + (from ? "/" + from + (howMany ? "/" + howMany : '') : ''), {
1232
1233
  method: 'GET',
1233
1234
  apiUrl: apiUrl
1234
1235
  }));
@@ -1241,7 +1242,7 @@ var correlationPairs = (function (apiUrl) {
1241
1242
  }, _callee);
1242
1243
  }));
1243
1244
 
1244
- function getCorrelationPairs(_x) {
1245
+ function getCorrelationPairs(_x, _x2, _x3) {
1245
1246
  return _getCorrelationPairs.apply(this, arguments);
1246
1247
  }
1247
1248
 
@@ -1249,19 +1250,20 @@ var correlationPairs = (function (apiUrl) {
1249
1250
  }(),
1250
1251
 
1251
1252
  /**
1252
- * Removes an existing Correlation Pair object.
1253
+ * Adds a new Correlation Pair object.
1253
1254
  * @param {string} sessionId The session ID
1254
- * @param {string} pairId The Correlation Pair object ID
1255
+ * @param {CorrelationPair} correlationPair The Correlation Pair object
1255
1256
  */
1256
- deleteCorrelationPair: function () {
1257
- var _deleteCorrelationPair = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, pairId) {
1257
+ postCorrelationPair: function () {
1258
+ var _postCorrelationPair = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, correlationPair) {
1258
1259
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1259
1260
  while (1) {
1260
1261
  switch (_context2.prev = _context2.next) {
1261
1262
  case 0:
1262
- return _context2.abrupt("return", apiFetcher("/CorrelationPair/" + sessionId + "/" + pairId, {
1263
- method: 'GET',
1264
- apiUrl: apiUrl
1263
+ return _context2.abrupt("return", apiFetcher("/CorrelationPair/" + sessionId, {
1264
+ method: 'POST',
1265
+ apiUrl: apiUrl,
1266
+ body: correlationPair
1265
1267
  }));
1266
1268
 
1267
1269
  case 1:
@@ -1272,7 +1274,38 @@ var correlationPairs = (function (apiUrl) {
1272
1274
  }, _callee2);
1273
1275
  }));
1274
1276
 
1275
- function deleteCorrelationPair(_x2, _x3) {
1277
+ function postCorrelationPair(_x4, _x5) {
1278
+ return _postCorrelationPair.apply(this, arguments);
1279
+ }
1280
+
1281
+ return postCorrelationPair;
1282
+ }(),
1283
+
1284
+ /**
1285
+ * Removes an existing Correlation Pair object.
1286
+ * @param {string} sessionId The session ID
1287
+ * @param {string} pairId The Correlation Pair object ID
1288
+ */
1289
+ deleteCorrelationPair: function () {
1290
+ var _deleteCorrelationPair = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, pairId) {
1291
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1292
+ while (1) {
1293
+ switch (_context3.prev = _context3.next) {
1294
+ case 0:
1295
+ return _context3.abrupt("return", apiFetcher("/CorrelationPair/" + sessionId + "/" + pairId, {
1296
+ method: 'DELETE',
1297
+ apiUrl: apiUrl
1298
+ }));
1299
+
1300
+ case 1:
1301
+ case "end":
1302
+ return _context3.stop();
1303
+ }
1304
+ }
1305
+ }, _callee3);
1306
+ }));
1307
+
1308
+ function deleteCorrelationPair(_x6, _x7) {
1276
1309
  return _deleteCorrelationPair.apply(this, arguments);
1277
1310
  }
1278
1311
 
@@ -2352,14 +2385,15 @@ var memories = (function (apiUrl) {
2352
2385
  /**
2353
2386
  * Lists all Memory objects.
2354
2387
  * @param {string} sessionId The session ID
2388
+ * @param {string=} type Optional type of the Memory objects to list: ALL, CONTENTS, DEFAULTS, DRAFTS
2355
2389
  */
2356
2390
  getMemories: function () {
2357
- var _getMemories = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId) {
2391
+ var _getMemories = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sessionId, type) {
2358
2392
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2359
2393
  while (1) {
2360
2394
  switch (_context.prev = _context.next) {
2361
2395
  case 0:
2362
- return _context.abrupt("return", apiFetcher("/Memories/" + sessionId, {
2396
+ return _context.abrupt("return", apiFetcher("/Memories/" + sessionId + (type ? "/" + type : ''), {
2363
2397
  method: 'GET',
2364
2398
  apiUrl: apiUrl
2365
2399
  }));
@@ -2372,7 +2406,7 @@ var memories = (function (apiUrl) {
2372
2406
  }, _callee);
2373
2407
  }));
2374
2408
 
2375
- function getMemories(_x) {
2409
+ function getMemories(_x, _x2) {
2376
2410
  return _getMemories.apply(this, arguments);
2377
2411
  }
2378
2412
 
@@ -2384,7 +2418,7 @@ var memories = (function (apiUrl) {
2384
2418
  * @param {string} sessionId The session ID
2385
2419
  * @param {number} from The starting index
2386
2420
  * @param {number} howMany The number of items to return
2387
- * @param {string=} type Optional type of the Memory objects to list: ALL, CONTENTS, DEFAULTS
2421
+ * @param {string=} type Optional type of the Memory objects to list: ALL, CONTENTS, DEFAULTS, DRAFTS
2388
2422
  */
2389
2423
  getMemoriesPaginated: function () {
2390
2424
  var _getMemoriesPaginated = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, from, howMany, type) {
@@ -2405,7 +2439,7 @@ var memories = (function (apiUrl) {
2405
2439
  }, _callee2);
2406
2440
  }));
2407
2441
 
2408
- function getMemoriesPaginated(_x2, _x3, _x4, _x5) {
2442
+ function getMemoriesPaginated(_x3, _x4, _x5, _x6) {
2409
2443
  return _getMemoriesPaginated.apply(this, arguments);
2410
2444
  }
2411
2445
 
@@ -2436,7 +2470,7 @@ var memories = (function (apiUrl) {
2436
2470
  }, _callee3);
2437
2471
  }));
2438
2472
 
2439
- function getMemory(_x6, _x7) {
2473
+ function getMemory(_x7, _x8) {
2440
2474
  return _getMemory.apply(this, arguments);
2441
2475
  }
2442
2476
 
@@ -2468,7 +2502,7 @@ var memories = (function (apiUrl) {
2468
2502
  }, _callee4);
2469
2503
  }));
2470
2504
 
2471
- function patchMemory(_x8, _x9) {
2505
+ function patchMemory(_x9, _x10) {
2472
2506
  return _patchMemory.apply(this, arguments);
2473
2507
  }
2474
2508
 
@@ -2499,7 +2533,7 @@ var memories = (function (apiUrl) {
2499
2533
  }, _callee5);
2500
2534
  }));
2501
2535
 
2502
- function deleteMemory(_x10, _x11) {
2536
+ function deleteMemory(_x11, _x12) {
2503
2537
  return _deleteMemory.apply(this, arguments);
2504
2538
  }
2505
2539
 
@@ -2531,7 +2565,7 @@ var memories = (function (apiUrl) {
2531
2565
  }, _callee6);
2532
2566
  }));
2533
2567
 
2534
- function postMemory(_x12, _x13) {
2568
+ function postMemory(_x13, _x14) {
2535
2569
  return _postMemory.apply(this, arguments);
2536
2570
  }
2537
2571
 
@@ -2562,7 +2596,7 @@ var memories = (function (apiUrl) {
2562
2596
  }, _callee7);
2563
2597
  }));
2564
2598
 
2565
- function getMemoryAccess(_x14, _x15) {
2599
+ function getMemoryAccess(_x15, _x16) {
2566
2600
  return _getMemoryAccess.apply(this, arguments);
2567
2601
  }
2568
2602
 
@@ -3551,31 +3585,63 @@ var unansweredQuestions = (function (apiUrl) {
3551
3585
  return getUnansweredQuestionsPaginated;
3552
3586
  }(),
3553
3587
 
3588
+ /**
3589
+ * Adds a new Unanswered Question object.
3590
+ * @param {string} sessionId The session ID
3591
+ * @param {UnansweredQuestion} unansweredQuestion The Unanswered Question object
3592
+ */
3593
+ postUnansweredQuestion: function () {
3594
+ var _postUnansweredQuestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, unansweredQuestion) {
3595
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3596
+ while (1) {
3597
+ switch (_context3.prev = _context3.next) {
3598
+ case 0:
3599
+ return _context3.abrupt("return", apiFetcher("/UnansweredQuestion/" + sessionId, {
3600
+ method: 'POST',
3601
+ apiUrl: apiUrl,
3602
+ body: unansweredQuestion
3603
+ }));
3604
+
3605
+ case 1:
3606
+ case "end":
3607
+ return _context3.stop();
3608
+ }
3609
+ }
3610
+ }, _callee3);
3611
+ }));
3612
+
3613
+ function postUnansweredQuestion(_x5, _x6) {
3614
+ return _postUnansweredQuestion.apply(this, arguments);
3615
+ }
3616
+
3617
+ return postUnansweredQuestion;
3618
+ }(),
3619
+
3554
3620
  /**
3555
3621
  * Removes an existing Unanswered Question object.
3556
3622
  * @param {string} sessionId The session ID
3557
3623
  * @param {string} unansweredQuestionId The Unanswered Question object ID
3558
3624
  */
3559
3625
  deleteUnansweredQuestion: function () {
3560
- var _deleteUnansweredQuestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, unansweredQuestionId) {
3561
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3626
+ var _deleteUnansweredQuestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(sessionId, unansweredQuestionId) {
3627
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3562
3628
  while (1) {
3563
- switch (_context3.prev = _context3.next) {
3629
+ switch (_context4.prev = _context4.next) {
3564
3630
  case 0:
3565
- return _context3.abrupt("return", apiFetcher("/UnansweredQuestion/" + sessionId + "/" + unansweredQuestionId, {
3631
+ return _context4.abrupt("return", apiFetcher("/UnansweredQuestion/" + sessionId + "/" + unansweredQuestionId, {
3566
3632
  method: 'DELETE',
3567
3633
  apiUrl: apiUrl
3568
3634
  }));
3569
3635
 
3570
3636
  case 1:
3571
3637
  case "end":
3572
- return _context3.stop();
3638
+ return _context4.stop();
3573
3639
  }
3574
3640
  }
3575
- }, _callee3);
3641
+ }, _callee4);
3576
3642
  }));
3577
3643
 
3578
- function deleteUnansweredQuestion(_x5, _x6) {
3644
+ function deleteUnansweredQuestion(_x7, _x8) {
3579
3645
  return _deleteUnansweredQuestion.apply(this, arguments);
3580
3646
  }
3581
3647
 
@@ -3892,6 +3958,37 @@ var chatLogs = (function (apiUrl) {
3892
3958
  return getChatLogs;
3893
3959
  }(),
3894
3960
 
3961
+ /**
3962
+ * Gets the Chat Log objects for the Memori of the current session recorded during a specific other session.
3963
+ * @param {string} sessionId The session ID
3964
+ * @param {string} chatLogSessionID The session ID for which Chat Log objects are being searched
3965
+ */
3966
+ getSessionChatLogs: function () {
3967
+ var _getSessionChatLogs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, chatLogSessionID) {
3968
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3969
+ while (1) {
3970
+ switch (_context2.prev = _context2.next) {
3971
+ case 0:
3972
+ return _context2.abrupt("return", apiFetcher("/SessionChatLogs/" + sessionId + "/" + chatLogSessionID, {
3973
+ method: 'GET',
3974
+ apiUrl: apiUrl
3975
+ }));
3976
+
3977
+ case 1:
3978
+ case "end":
3979
+ return _context2.stop();
3980
+ }
3981
+ }
3982
+ }, _callee2);
3983
+ }));
3984
+
3985
+ function getSessionChatLogs(_x4, _x5) {
3986
+ return _getSessionChatLogs.apply(this, arguments);
3987
+ }
3988
+
3989
+ return getSessionChatLogs;
3990
+ }(),
3991
+
3895
3992
  /**
3896
3993
  * Removes all Chat Log objects in a specific date internval.
3897
3994
  * @param {string} sessionId The session ID
@@ -3899,25 +3996,25 @@ var chatLogs = (function (apiUrl) {
3899
3996
  * @param {?string} dateTo The optional end of the date interval, in UTC time, in the format yyyyMMddHHmmssfff
3900
3997
  */
3901
3998
  deleteChatLogs: function () {
3902
- var _deleteChatLogs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sessionId, dateFrom, dateTo) {
3903
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3999
+ var _deleteChatLogs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, dateFrom, dateTo) {
4000
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3904
4001
  while (1) {
3905
- switch (_context2.prev = _context2.next) {
4002
+ switch (_context3.prev = _context3.next) {
3906
4003
  case 0:
3907
- return _context2.abrupt("return", apiFetcher("/ChatLogs/" + sessionId + (dateFrom ? "/" + dateFrom : '') + (dateFrom && dateTo ? "/" + dateTo : ''), {
4004
+ return _context3.abrupt("return", apiFetcher("/ChatLogs/" + sessionId + (dateFrom ? "/" + dateFrom : '') + (dateFrom && dateTo ? "/" + dateTo : ''), {
3908
4005
  method: 'DELETE',
3909
4006
  apiUrl: apiUrl
3910
4007
  }));
3911
4008
 
3912
4009
  case 1:
3913
4010
  case "end":
3914
- return _context2.stop();
4011
+ return _context3.stop();
3915
4012
  }
3916
4013
  }
3917
- }, _callee2);
4014
+ }, _callee3);
3918
4015
  }));
3919
4016
 
3920
- function deleteChatLogs(_x4, _x5, _x6) {
4017
+ function deleteChatLogs(_x6, _x7, _x8) {
3921
4018
  return _deleteChatLogs.apply(this, arguments);
3922
4019
  }
3923
4020
 
@@ -3930,25 +4027,25 @@ var chatLogs = (function (apiUrl) {
3930
4027
  * @param {string} chatLogId The Chat Log object ID
3931
4028
  */
3932
4029
  deleteChatLog: function () {
3933
- var _deleteChatLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sessionId, chatLogId) {
3934
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4030
+ var _deleteChatLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(sessionId, chatLogId) {
4031
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3935
4032
  while (1) {
3936
- switch (_context3.prev = _context3.next) {
4033
+ switch (_context4.prev = _context4.next) {
3937
4034
  case 0:
3938
- return _context3.abrupt("return", apiFetcher("/ChatLog/" + sessionId + "/" + chatLogId, {
4035
+ return _context4.abrupt("return", apiFetcher("/ChatLog/" + sessionId + "/" + chatLogId, {
3939
4036
  method: 'DELETE',
3940
4037
  apiUrl: apiUrl
3941
4038
  }));
3942
4039
 
3943
4040
  case 1:
3944
4041
  case "end":
3945
- return _context3.stop();
4042
+ return _context4.stop();
3946
4043
  }
3947
4044
  }
3948
- }, _callee3);
4045
+ }, _callee4);
3949
4046
  }));
3950
4047
 
3951
- function deleteChatLog(_x7, _x8) {
4048
+ function deleteChatLog(_x9, _x10) {
3952
4049
  return _deleteChatLog.apply(this, arguments);
3953
4050
  }
3954
4051
 
@@ -4004,239 +4101,6 @@ var constants = {
4004
4101
  anonTag: anonTag
4005
4102
  };
4006
4103
 
4007
- var getTTSVoice = function getTTSVoice(lang, voiceType) {
4008
- var voice = '';
4009
- var voiceLang = lang.toUpperCase();
4010
-
4011
- switch (voiceLang) {
4012
- case 'IT':
4013
- voice = "" + (voiceType === 'MALE' ? 'it-IT-DiegoNeural' : 'it-IT-ElsaNeural');
4014
- break;
4015
-
4016
- case 'DE':
4017
- voice = "" + (voiceType === 'MALE' ? 'de-DE-ConradNeural' : 'de-DE-KatjaNeural');
4018
- break;
4019
-
4020
- case 'EN':
4021
- voice = "" + (voiceType === 'MALE' ? 'en-GB-RyanNeural' : 'en-GB-SoniaNeural');
4022
- break;
4023
-
4024
- case 'ES':
4025
- voice = "" + (voiceType === 'MALE' ? 'es-ES-AlvaroNeural' : 'es-ES-ElviraNeural');
4026
- break;
4027
-
4028
- case 'FR':
4029
- voice = "" + (voiceType === 'MALE' ? 'fr-FR-HenriNeural' : 'fr-FR-DeniseNeural');
4030
- break;
4031
-
4032
- case 'PT':
4033
- voice = "" + (voiceType === 'MALE' ? 'pt-PT-DuarteNeural' : 'pt-PT-RaquelNeural');
4034
- break;
4035
-
4036
- default:
4037
- voice = "" + (voiceType === 'MALE' ? 'it-IT-DiegoNeural' : 'it-IT-IsabellaNeural');
4038
- break;
4039
- }
4040
-
4041
- return voice;
4042
- };
4043
-
4044
- var getCultureCodeByLanguage = function getCultureCodeByLanguage(lang) {
4045
- var voice = '';
4046
- var voiceLang = lang.toUpperCase();
4047
-
4048
- switch (voiceLang) {
4049
- case 'IT':
4050
- voice = 'it-IT';
4051
- break;
4052
-
4053
- case 'DE':
4054
- voice = 'de-DE';
4055
- break;
4056
-
4057
- case 'EN':
4058
- voice = 'en-US';
4059
- break;
4060
-
4061
- case 'ES':
4062
- voice = 'es-ES';
4063
- break;
4064
-
4065
- case 'FR':
4066
- voice = 'fr-FR';
4067
- break;
4068
-
4069
- case 'PT':
4070
- voice = 'pt-PT';
4071
- break;
4072
-
4073
- default:
4074
- voice = 'it-IT';
4075
- break;
4076
- }
4077
-
4078
- return voice;
4079
- };
4080
- /**
4081
- * EXPERIMENTAL
4082
- */
4083
-
4084
-
4085
- var speech = function speech(AZURE_COGNITIVE_SERVICES_TTS_KEY, DEBUG) {
4086
- if (DEBUG === void 0) {
4087
- DEBUG = false;
4088
- }
4089
-
4090
- return function (lang, voiceType) {
4091
- var speechConfig = SpeechConfig.fromSubscription(AZURE_COGNITIVE_SERVICES_TTS_KEY, 'eastus');
4092
- var speechSynthesizer;
4093
- var audioDestination;
4094
- audioDestination = new SpeakerAudioDestination();
4095
- var audioOutputConfig = AudioConfig.fromSpeakerOutput(audioDestination); // https://docs.microsoft.com/it-it/azure/cognitive-services/speech-service/language-support#text-to-speech
4096
-
4097
- speechConfig.speechSynthesisVoiceName = getTTSVoice(lang, voiceType);
4098
- var langCultureCode = getCultureCodeByLanguage(lang);
4099
- speechConfig.speechSynthesisLanguage = langCultureCode;
4100
- speechConfig.speechRecognitionLanguage = langCultureCode;
4101
- /**
4102
- * speak
4103
- * @description Speaks the text using the speech synthesizer. (TTS)
4104
- * @param {string} text - The text to be synthesized.
4105
- * @param {func=} onAudioEnd - The callback to be invoked when the synthesized audio is finished.
4106
- */
4107
-
4108
- var speak = function speak(text, onAudioEnd) {
4109
- stopSpeaking();
4110
- speechSynthesizer = new SpeechSynthesizer(speechConfig, audioOutputConfig);
4111
- if (onAudioEnd) audioDestination.onAudioEnd = onAudioEnd;
4112
- speechSynthesizer.speakTextAsync(text, function (result) {
4113
- if (result) {
4114
- try {
4115
- if (DEBUG) console.log('speak result', result);
4116
-
4117
- if (speechSynthesizer) {
4118
- speechSynthesizer.close();
4119
- speechSynthesizer = null;
4120
- }
4121
- } catch (e) {
4122
- console.error('speak error: ', e);
4123
- window.speechSynthesis.speak(new SpeechSynthesisUtterance(text));
4124
- }
4125
- } else if (DEBUG) {
4126
- console.log('speak no result', result);
4127
- }
4128
- }, function (error) {
4129
- console.error('speak:', error);
4130
- window.speechSynthesis.speak(new SpeechSynthesisUtterance(text));
4131
- });
4132
- };
4133
- /**
4134
- * isSpeaking
4135
- * @description Returns true if the synthesizer is speaking.
4136
- * @returns {boolean}
4137
- */
4138
-
4139
-
4140
- var isSpeaking = function isSpeaking() {
4141
- return !!speechSynthesizer;
4142
- };
4143
- /**
4144
- * stopSpeaking
4145
- * @description Stops the speech synthesizer if it is synthesizing.
4146
- */
4147
-
4148
-
4149
- var stopSpeaking = function stopSpeaking() {
4150
- if (audioDestination) audioDestination.pause();
4151
-
4152
- if (speechSynthesizer) {
4153
- speechSynthesizer.close();
4154
- speechSynthesizer = null;
4155
- }
4156
- };
4157
-
4158
- var audioInputConfig = AudioConfig.fromDefaultMicrophoneInput();
4159
- var recognizer;
4160
- /**
4161
- * recognize
4162
- * @description Starts the speech recognition.
4163
- * @param {func=} onRecognized - Callback method invoked when the speech is recognized with the text.
4164
- */
4165
-
4166
- var recognize = function recognize(onRecognized) {
4167
- recognizer = new SpeechRecognizer(speechConfig, audioInputConfig);
4168
-
4169
- recognizer.recognizing = function (_s, e) {
4170
- if (DEBUG) console.log("RECOGNIZING: Text=" + e.result.text);
4171
- };
4172
-
4173
- recognizer.recognized = function (_s, e) {
4174
- if (e.result.reason === ResultReason.RecognizedSpeech) {
4175
- var _e$result$text;
4176
-
4177
- if (DEBUG) console.log("RECOGNIZED: Text=" + e.result.text);
4178
- onRecognized((_e$result$text = e.result.text) != null ? _e$result$text : '');
4179
- } else if (e.result.reason === ResultReason.NoMatch && DEBUG) {
4180
- console.log('NOMATCH: Speech could not be recognized.');
4181
- }
4182
- };
4183
-
4184
- recognizer.canceled = function (_s, e) {
4185
- if (DEBUG) console.log("CANCELED: Reason=" + e.reason);
4186
-
4187
- if (e.reason === CancellationReason.Error && DEBUG) {
4188
- console.log("\"CANCELED: ErrorCode=" + e.errorCode);
4189
- console.log("\"CANCELED: ErrorDetails=" + e.errorDetails);
4190
- console.log('CANCELED: Did you set the speech resource key and region values?');
4191
- }
4192
-
4193
- stopRecognizing();
4194
- };
4195
-
4196
- recognizer.sessionStopped = function (_s, _e) {
4197
- if (DEBUG) console.log('\n Session stopped event.');
4198
- if (recognizer) recognizer.stopContinuousRecognitionAsync();
4199
- };
4200
-
4201
- recognizer.startContinuousRecognitionAsync();
4202
- };
4203
- /**
4204
- * isRecognizing
4205
- * @description Returns true if the recognizer is recognizing.
4206
- * @returns {boolean}
4207
- */
4208
-
4209
-
4210
- var isRecognizing = function isRecognizing() {
4211
- return !!recognizer;
4212
- };
4213
- /**
4214
- * stopRecognizing
4215
- * @description Stops the speech recognizer if it is recognizing.
4216
- * @param {func=} onStop - (optional) The callback to be invoked when the speech recognition is stopped.
4217
- */
4218
-
4219
-
4220
- var stopRecognizing = function stopRecognizing(onStop) {
4221
- if (recognizer) {
4222
- recognizer.stopContinuousRecognitionAsync();
4223
- recognizer.close();
4224
- recognizer = null;
4225
- if (onStop) onStop();
4226
- }
4227
- };
4228
-
4229
- return {
4230
- speak: speak,
4231
- isSpeaking: isSpeaking,
4232
- stopSpeaking: stopSpeaking,
4233
- recognize: recognize,
4234
- isRecognizing: isRecognizing,
4235
- stopRecognizing: stopRecognizing
4236
- };
4237
- };
4238
- };
4239
-
4240
4104
  var asset$1 = (function (apiUrl) {
4241
4105
  return {
4242
4106
  /**
@@ -4279,7 +4143,6 @@ var api = function api(hostname) {
4279
4143
  return _extends({
4280
4144
  backend: backendAPI(apiUrl + "/api/v2")
4281
4145
  }, engine(apiUrl + "/memori/v2"), {
4282
- speech: speech,
4283
4146
  constants: constants,
4284
4147
  asset: asset$1(apiUrl + "/api/v2")
4285
4148
  });