@memori.ai/memori-api-client 0.11.0 → 1.1.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 */
@@ -406,7 +405,7 @@ function _extends() {
406
405
  }
407
406
 
408
407
  var getApiUrl = function getApiUrl(hostname) {
409
- return hostname ? new URL(hostname.startsWith('http') ? hostname : "https://" + hostname).origin.replace('http://', 'https://') : 'https://backend.memori.ai';
408
+ return hostname ? new URL(hostname.startsWith('http') ? hostname : "https://" + hostname).origin : 'https://backend.memori.ai';
410
409
  };
411
410
 
412
411
  var apiFetcher = function apiFetcher(path, opts) {
@@ -469,12 +468,38 @@ var memori = (function (apiUrl) {
469
468
  });
470
469
  },
471
470
 
471
+ /**
472
+ * Gets a list of Memori objects owned by the specified user.
473
+ * @param {string} tenantName - The name of the tenant
474
+ * @param {string} userID - The user name
475
+ * @param {string=} authToken - The login token
476
+ * @returns A list of Memori objects
477
+ */
478
+ getUserByIDMemoriList: function getUserByIDMemoriList(tenantName, userID, authToken) {
479
+ return apiFetcher("/UserMemoriByID/" + tenantName + "/" + userID + (authToken ? "/" + authToken : ''), {
480
+ apiUrl: apiUrl
481
+ });
482
+ },
483
+
484
+ /**
485
+ * Gets a list of Memori objects owned by the specified user.
486
+ * @param {string} tenantName - The name of the tenant
487
+ * @param {string} userName - The user name
488
+ * @param {string=} authToken - The login token
489
+ * @returns A list of Memori objects
490
+ */
491
+ getUserMemoriList: function getUserMemoriList(tenantName, userName, authToken) {
492
+ return apiFetcher("/UserMemori/" + tenantName + "/" + userName + (authToken ? "/" + authToken : ''), {
493
+ apiUrl: apiUrl
494
+ });
495
+ },
496
+
472
497
  /**
473
498
  * Gets a list of Memori objects for the currently logged in User.
474
499
  * @param authToken - The login token
475
500
  * @returns A list of Memori objects
476
501
  */
477
- getUserMemoriList: function getUserMemoriList(authToken) {
502
+ getMemoriList: function getMemoriList(authToken) {
478
503
  return apiFetcher("/Memori/" + authToken, {
479
504
  apiUrl: apiUrl
480
505
  });
@@ -643,7 +668,7 @@ var user = (function (apiUrl) {
643
668
  * @param user - The user object
644
669
  * @returns The created user object
645
670
  */
646
- userSignIn: function userSignIn(user) {
671
+ userSignUp: function userSignUp(user) {
647
672
  return apiFetcher('/User', {
648
673
  apiUrl: apiUrl,
649
674
  body: user,
@@ -656,7 +681,7 @@ var user = (function (apiUrl) {
656
681
  * @param user - The user object
657
682
  * @returns The created user object
658
683
  */
659
- userConfirmSignIn: function userConfirmSignIn(user) {
684
+ userConfirmSignUp: function userConfirmSignUp(user) {
660
685
  return apiFetcher('/UserConfirm', {
661
686
  apiUrl: apiUrl,
662
687
  body: user,
@@ -4108,239 +4133,6 @@ var constants = {
4108
4133
  anonTag: anonTag
4109
4134
  };
4110
4135
 
4111
- var getTTSVoice = function getTTSVoice(lang, voiceType) {
4112
- var voice = '';
4113
- var voiceLang = lang.toUpperCase();
4114
-
4115
- switch (voiceLang) {
4116
- case 'IT':
4117
- voice = "" + (voiceType === 'MALE' ? 'it-IT-DiegoNeural' : 'it-IT-ElsaNeural');
4118
- break;
4119
-
4120
- case 'DE':
4121
- voice = "" + (voiceType === 'MALE' ? 'de-DE-ConradNeural' : 'de-DE-KatjaNeural');
4122
- break;
4123
-
4124
- case 'EN':
4125
- voice = "" + (voiceType === 'MALE' ? 'en-GB-RyanNeural' : 'en-GB-SoniaNeural');
4126
- break;
4127
-
4128
- case 'ES':
4129
- voice = "" + (voiceType === 'MALE' ? 'es-ES-AlvaroNeural' : 'es-ES-ElviraNeural');
4130
- break;
4131
-
4132
- case 'FR':
4133
- voice = "" + (voiceType === 'MALE' ? 'fr-FR-HenriNeural' : 'fr-FR-DeniseNeural');
4134
- break;
4135
-
4136
- case 'PT':
4137
- voice = "" + (voiceType === 'MALE' ? 'pt-PT-DuarteNeural' : 'pt-PT-RaquelNeural');
4138
- break;
4139
-
4140
- default:
4141
- voice = "" + (voiceType === 'MALE' ? 'it-IT-DiegoNeural' : 'it-IT-IsabellaNeural');
4142
- break;
4143
- }
4144
-
4145
- return voice;
4146
- };
4147
-
4148
- var getCultureCodeByLanguage = function getCultureCodeByLanguage(lang) {
4149
- var voice = '';
4150
- var voiceLang = lang.toUpperCase();
4151
-
4152
- switch (voiceLang) {
4153
- case 'IT':
4154
- voice = 'it-IT';
4155
- break;
4156
-
4157
- case 'DE':
4158
- voice = 'de-DE';
4159
- break;
4160
-
4161
- case 'EN':
4162
- voice = 'en-US';
4163
- break;
4164
-
4165
- case 'ES':
4166
- voice = 'es-ES';
4167
- break;
4168
-
4169
- case 'FR':
4170
- voice = 'fr-FR';
4171
- break;
4172
-
4173
- case 'PT':
4174
- voice = 'pt-PT';
4175
- break;
4176
-
4177
- default:
4178
- voice = 'it-IT';
4179
- break;
4180
- }
4181
-
4182
- return voice;
4183
- };
4184
- /**
4185
- * EXPERIMENTAL
4186
- */
4187
-
4188
-
4189
- var speech = function speech(AZURE_COGNITIVE_SERVICES_TTS_KEY, DEBUG) {
4190
- if (DEBUG === void 0) {
4191
- DEBUG = false;
4192
- }
4193
-
4194
- return function (lang, voiceType) {
4195
- var speechConfig = speechSdk.SpeechConfig.fromSubscription(AZURE_COGNITIVE_SERVICES_TTS_KEY, 'eastus');
4196
- var speechSynthesizer;
4197
- var audioDestination;
4198
- audioDestination = new speechSdk.SpeakerAudioDestination();
4199
- var audioOutputConfig = speechSdk.AudioConfig.fromSpeakerOutput(audioDestination); // https://docs.microsoft.com/it-it/azure/cognitive-services/speech-service/language-support#text-to-speech
4200
-
4201
- speechConfig.speechSynthesisVoiceName = getTTSVoice(lang, voiceType);
4202
- var langCultureCode = getCultureCodeByLanguage(lang);
4203
- speechConfig.speechSynthesisLanguage = langCultureCode;
4204
- speechConfig.speechRecognitionLanguage = langCultureCode;
4205
- /**
4206
- * speak
4207
- * @description Speaks the text using the speech synthesizer. (TTS)
4208
- * @param {string} text - The text to be synthesized.
4209
- * @param {func=} onAudioEnd - The callback to be invoked when the synthesized audio is finished.
4210
- */
4211
-
4212
- var speak = function speak(text, onAudioEnd) {
4213
- stopSpeaking();
4214
- speechSynthesizer = new speechSdk.SpeechSynthesizer(speechConfig, audioOutputConfig);
4215
- if (onAudioEnd) audioDestination.onAudioEnd = onAudioEnd;
4216
- speechSynthesizer.speakTextAsync(text, function (result) {
4217
- if (result) {
4218
- try {
4219
- if (DEBUG) console.log('speak result', result);
4220
-
4221
- if (speechSynthesizer) {
4222
- speechSynthesizer.close();
4223
- speechSynthesizer = null;
4224
- }
4225
- } catch (e) {
4226
- console.error('speak error: ', e);
4227
- window.speechSynthesis.speak(new SpeechSynthesisUtterance(text));
4228
- }
4229
- } else if (DEBUG) {
4230
- console.log('speak no result', result);
4231
- }
4232
- }, function (error) {
4233
- console.error('speak:', error);
4234
- window.speechSynthesis.speak(new SpeechSynthesisUtterance(text));
4235
- });
4236
- };
4237
- /**
4238
- * isSpeaking
4239
- * @description Returns true if the synthesizer is speaking.
4240
- * @returns {boolean}
4241
- */
4242
-
4243
-
4244
- var isSpeaking = function isSpeaking() {
4245
- return !!speechSynthesizer;
4246
- };
4247
- /**
4248
- * stopSpeaking
4249
- * @description Stops the speech synthesizer if it is synthesizing.
4250
- */
4251
-
4252
-
4253
- var stopSpeaking = function stopSpeaking() {
4254
- if (audioDestination) audioDestination.pause();
4255
-
4256
- if (speechSynthesizer) {
4257
- speechSynthesizer.close();
4258
- speechSynthesizer = null;
4259
- }
4260
- };
4261
-
4262
- var audioInputConfig = speechSdk.AudioConfig.fromDefaultMicrophoneInput();
4263
- var recognizer;
4264
- /**
4265
- * recognize
4266
- * @description Starts the speech recognition.
4267
- * @param {func=} onRecognized - Callback method invoked when the speech is recognized with the text.
4268
- */
4269
-
4270
- var recognize = function recognize(onRecognized) {
4271
- recognizer = new speechSdk.SpeechRecognizer(speechConfig, audioInputConfig);
4272
-
4273
- recognizer.recognizing = function (_s, e) {
4274
- if (DEBUG) console.log("RECOGNIZING: Text=" + e.result.text);
4275
- };
4276
-
4277
- recognizer.recognized = function (_s, e) {
4278
- if (e.result.reason === speechSdk.ResultReason.RecognizedSpeech) {
4279
- var _e$result$text;
4280
-
4281
- if (DEBUG) console.log("RECOGNIZED: Text=" + e.result.text);
4282
- onRecognized((_e$result$text = e.result.text) != null ? _e$result$text : '');
4283
- } else if (e.result.reason === speechSdk.ResultReason.NoMatch && DEBUG) {
4284
- console.log('NOMATCH: Speech could not be recognized.');
4285
- }
4286
- };
4287
-
4288
- recognizer.canceled = function (_s, e) {
4289
- if (DEBUG) console.log("CANCELED: Reason=" + e.reason);
4290
-
4291
- if (e.reason === speechSdk.CancellationReason.Error && DEBUG) {
4292
- console.log("\"CANCELED: ErrorCode=" + e.errorCode);
4293
- console.log("\"CANCELED: ErrorDetails=" + e.errorDetails);
4294
- console.log('CANCELED: Did you set the speech resource key and region values?');
4295
- }
4296
-
4297
- stopRecognizing();
4298
- };
4299
-
4300
- recognizer.sessionStopped = function (_s, _e) {
4301
- if (DEBUG) console.log('\n Session stopped event.');
4302
- if (recognizer) recognizer.stopContinuousRecognitionAsync();
4303
- };
4304
-
4305
- recognizer.startContinuousRecognitionAsync();
4306
- };
4307
- /**
4308
- * isRecognizing
4309
- * @description Returns true if the recognizer is recognizing.
4310
- * @returns {boolean}
4311
- */
4312
-
4313
-
4314
- var isRecognizing = function isRecognizing() {
4315
- return !!recognizer;
4316
- };
4317
- /**
4318
- * stopRecognizing
4319
- * @description Stops the speech recognizer if it is recognizing.
4320
- * @param {func=} onStop - (optional) The callback to be invoked when the speech recognition is stopped.
4321
- */
4322
-
4323
-
4324
- var stopRecognizing = function stopRecognizing(onStop) {
4325
- if (recognizer) {
4326
- recognizer.stopContinuousRecognitionAsync();
4327
- recognizer.close();
4328
- recognizer = null;
4329
- if (onStop) onStop();
4330
- }
4331
- };
4332
-
4333
- return {
4334
- speak: speak,
4335
- isSpeaking: isSpeaking,
4336
- stopSpeaking: stopSpeaking,
4337
- recognize: recognize,
4338
- isRecognizing: isRecognizing,
4339
- stopRecognizing: stopRecognizing
4340
- };
4341
- };
4342
- };
4343
-
4344
4136
  var asset$1 = (function (apiUrl) {
4345
4137
  return {
4346
4138
  /**
@@ -4383,7 +4175,6 @@ var api = function api(hostname) {
4383
4175
  return _extends({
4384
4176
  backend: backendAPI(apiUrl + "/api/v2")
4385
4177
  }, engine(apiUrl + "/memori/v2"), {
4386
- speech: speech,
4387
4178
  constants: constants,
4388
4179
  asset: asset$1(apiUrl + "/api/v2")
4389
4180
  });