@aws-amplify/predictions 6.0.22 → 6.0.23

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.
Files changed (41) hide show
  1. package/dist/cjs/Predictions.js +2 -4
  2. package/dist/cjs/Predictions.js.map +1 -1
  3. package/dist/cjs/providers/AmazonAIConvertPredictionsProvider.js +9 -9
  4. package/dist/cjs/providers/AmazonAIConvertPredictionsProvider.js.map +1 -1
  5. package/dist/cjs/providers/AmazonAIIdentifyPredictionsProvider.js +25 -20
  6. package/dist/cjs/providers/AmazonAIIdentifyPredictionsProvider.js.map +1 -1
  7. package/dist/cjs/providers/AmazonAIInterpretPredictionsProvider.js +7 -7
  8. package/dist/cjs/providers/AmazonAIInterpretPredictionsProvider.js.map +1 -1
  9. package/dist/cjs/providers/IdentifyTextUtils.js +9 -9
  10. package/dist/cjs/providers/IdentifyTextUtils.js.map +1 -1
  11. package/dist/cjs/providers/Utils.js +6 -6
  12. package/dist/cjs/providers/Utils.js.map +1 -1
  13. package/dist/cjs/types/Predictions.js +15 -14
  14. package/dist/cjs/types/Predictions.js.map +1 -1
  15. package/dist/esm/Predictions.mjs +0 -2
  16. package/dist/esm/Predictions.mjs.map +1 -1
  17. package/dist/esm/providers/AmazonAIConvertPredictionsProvider.mjs +9 -9
  18. package/dist/esm/providers/AmazonAIConvertPredictionsProvider.mjs.map +1 -1
  19. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.d.ts +6 -6
  20. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.mjs +25 -20
  21. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.mjs.map +1 -1
  22. package/dist/esm/providers/AmazonAIInterpretPredictionsProvider.mjs +7 -7
  23. package/dist/esm/providers/AmazonAIInterpretPredictionsProvider.mjs.map +1 -1
  24. package/dist/esm/providers/IdentifyTextUtils.mjs +9 -9
  25. package/dist/esm/providers/IdentifyTextUtils.mjs.map +1 -1
  26. package/dist/esm/providers/Utils.mjs +6 -6
  27. package/dist/esm/providers/Utils.mjs.map +1 -1
  28. package/dist/esm/types/AWSTypes.d.ts +2 -2
  29. package/dist/esm/types/Predictions.d.ts +30 -30
  30. package/dist/esm/types/Predictions.mjs +15 -14
  31. package/dist/esm/types/Predictions.mjs.map +1 -1
  32. package/package.json +6 -5
  33. package/src/Predictions.ts +2 -3
  34. package/src/providers/AmazonAIConvertPredictionsProvider.ts +20 -10
  35. package/src/providers/AmazonAIIdentifyPredictionsProvider.ts +41 -26
  36. package/src/providers/AmazonAIInterpretPredictionsProvider.ts +22 -18
  37. package/src/providers/IdentifyTextUtils.ts +25 -22
  38. package/src/providers/Utils.ts +8 -6
  39. package/src/providers/index.ts +1 -0
  40. package/src/types/AWSTypes.ts +2 -3
  41. package/src/types/Predictions.ts +60 -44
@@ -1,12 +1,10 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Predictions = exports.PredictionsClass = void 0;
5
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
4
  // SPDX-License-Identifier: Apache-2.0
7
- const core_1 = require("@aws-amplify/core");
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Predictions = exports.PredictionsClass = void 0;
8
7
  const providers_1 = require("./providers");
9
- new core_1.ConsoleLogger('Predictions');
10
8
  class PredictionsClass {
11
9
  constructor() {
12
10
  this.convertProvider = new providers_1.AmazonAIConvertPredictionsProvider();
@@ -1 +1 @@
1
- {"version":3,"file":"Predictions.js","sources":["../../src/Predictions.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Predictions = exports.PredictionsClass = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst providers_1 = require(\"./providers\");\nconst logger = new core_1.ConsoleLogger('Predictions');\nclass PredictionsClass {\n constructor() {\n this.convertProvider = new providers_1.AmazonAIConvertPredictionsProvider();\n this.identifyProvider = new providers_1.AmazonAIIdentifyPredictionsProvider();\n this.interpretProvider = new providers_1.AmazonAIInterpretPredictionsProvider();\n }\n getModuleName() {\n return 'Predictions';\n }\n interpret(input) {\n return this.interpretProvider.interpret(input);\n }\n convert(input) {\n return this.convertProvider.convert(input);\n }\n identify(input) {\n return this.identifyProvider.identify(input);\n }\n}\nexports.PredictionsClass = PredictionsClass;\nexports.Predictions = new PredictionsClass();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACxD;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC5B,IAAI,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE;AACvD,MAAM,gBAAgB,CAAC;AACvB,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI,WAAW,CAAC,kCAAkC,EAAE,CAAC;AACpF,QAAQ,IAAI,CAAC,gBAAgB,GAAG,IAAI,WAAW,CAAC,mCAAmC,EAAE,CAAC;AACtF,QAAQ,IAAI,CAAC,iBAAiB,GAAG,IAAI,WAAW,CAAC,oCAAoC,EAAE,CAAC;AACxF,KAAK;AACL,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,aAAa,CAAC;AAC7B,KAAK;AACL,IAAI,SAAS,CAAC,KAAK,EAAE;AACrB,QAAQ,OAAO,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvD,KAAK;AACL,IAAI,OAAO,CAAC,KAAK,EAAE;AACnB,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,QAAQ,CAAC,KAAK,EAAE;AACpB,QAAQ,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C,OAAO,CAAC,WAAW,GAAG,IAAI,gBAAgB,EAAE;;"}
1
+ {"version":3,"file":"Predictions.js","sources":["../../src/Predictions.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Predictions = exports.PredictionsClass = void 0;\nconst providers_1 = require(\"./providers\");\nclass PredictionsClass {\n constructor() {\n this.convertProvider = new providers_1.AmazonAIConvertPredictionsProvider();\n this.identifyProvider = new providers_1.AmazonAIIdentifyPredictionsProvider();\n this.interpretProvider = new providers_1.AmazonAIInterpretPredictionsProvider();\n }\n getModuleName() {\n return 'Predictions';\n }\n interpret(input) {\n return this.interpretProvider.interpret(input);\n }\n convert(input) {\n return this.convertProvider.convert(input);\n }\n identify(input) {\n return this.identifyProvider.identify(input);\n }\n}\nexports.PredictionsClass = PredictionsClass;\nexports.Predictions = new PredictionsClass();\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACxD,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC3C,MAAM,gBAAgB,CAAC;AACvB,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI,WAAW,CAAC,kCAAkC,EAAE,CAAC;AACpF,QAAQ,IAAI,CAAC,gBAAgB,GAAG,IAAI,WAAW,CAAC,mCAAmC,EAAE,CAAC;AACtF,QAAQ,IAAI,CAAC,iBAAiB,GAAG,IAAI,WAAW,CAAC,oCAAoC,EAAE,CAAC;AACxF,KAAK;AACL,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,aAAa,CAAC;AAC7B,KAAK;AACL,IAAI,SAAS,CAAC,KAAK,EAAE;AACrB,QAAQ,OAAO,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvD,KAAK;AACL,IAAI,OAAO,CAAC,KAAK,EAAE;AACnB,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,QAAQ,CAAC,KAAK,EAAE;AACpB,QAAQ,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C,OAAO,CAAC,WAAW,GAAG,IAAI,gBAAgB,EAAE;;"}
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.AmazonAIConvertPredictionsProvider = void 0;
5
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
6
  // SPDX-License-Identifier: Apache-2.0
7
+ const buffer_1 = require("buffer");
7
8
  const core_1 = require("@aws-amplify/core");
8
9
  const utils_1 = require("@aws-amplify/core/internals/utils");
9
10
  const client_polly_1 = require("@aws-sdk/client-polly");
10
11
  const client_translate_1 = require("@aws-sdk/client-translate");
11
12
  const eventstream_codec_1 = require("@smithy/eventstream-codec");
12
13
  const util_utf8_1 = require("@smithy/util-utf8");
13
- const buffer_1 = require("buffer");
14
14
  const validation_1 = require("../errors/types/validation");
15
15
  const assertValidationError_1 = require("../errors/utils/assertValidationError");
16
16
  const types_1 = require("../types");
@@ -94,7 +94,6 @@ class AmazonAIConvertPredictionsProvider {
94
94
  VoiceId: voiceId,
95
95
  TextType: 'text',
96
96
  SampleRate: '24000',
97
- // tslint:disable-next-line: align
98
97
  });
99
98
  const data = await this.pollyClient.send(synthesizeSpeechCommand);
100
99
  const response = new Response(data.AudioStream);
@@ -167,7 +166,7 @@ class AmazonAIConvertPredictionsProvider {
167
166
  return decodedMessage;
168
167
  }
169
168
  sendDataToTranscribe({ connection, raw, languageCode, }) {
170
- return new Promise((res, rej) => {
169
+ return new Promise((resolve, reject) => {
171
170
  let fullText = '';
172
171
  connection.onmessage = message => {
173
172
  try {
@@ -178,16 +177,16 @@ class AmazonAIConvertPredictionsProvider {
178
177
  }
179
178
  catch (err) {
180
179
  logger.debug(err);
181
- rej(err);
180
+ reject(err);
182
181
  }
183
182
  };
184
183
  connection.onerror = errorEvent => {
185
184
  logger.debug({ errorEvent });
186
- rej('failed to transcribe, network error');
185
+ reject(new Error('failed to transcribe, network error'));
187
186
  };
188
187
  connection.onclose = closeEvent => {
189
188
  logger.debug({ closeEvent });
190
- return res(fullText.trim());
189
+ resolve(fullText.trim());
191
190
  };
192
191
  logger.debug({ raw });
193
192
  if (Array.isArray(raw)) {
@@ -261,7 +260,8 @@ class AmazonAIConvertPredictionsProvider {
261
260
  let offsetBuffer = 0;
262
261
  while (offsetResult < result.length) {
263
262
  const nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);
264
- let accum = 0, count = 0;
263
+ let accum = 0;
264
+ let count = 0;
265
265
  for (let i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {
266
266
  accum += buffer[i];
267
267
  count++;
@@ -273,7 +273,7 @@ class AmazonAIConvertPredictionsProvider {
273
273
  return result;
274
274
  }
275
275
  openConnectionWithTranscribe({ credentials, region, languageCode, }) {
276
- return new Promise(async (res, rej) => {
276
+ return new Promise((resolve, _reject) => {
277
277
  const signedUrl = this.generateTranscribeUrl({
278
278
  credentials,
279
279
  region,
@@ -284,7 +284,7 @@ class AmazonAIConvertPredictionsProvider {
284
284
  connection.binaryType = 'arraybuffer';
285
285
  connection.onopen = () => {
286
286
  logger.debug('connected');
287
- res(connection);
287
+ resolve(connection);
288
288
  };
289
289
  });
290
290
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AmazonAIConvertPredictionsProvider.js","sources":["../../../src/providers/AmazonAIConvertPredictionsProvider.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmazonAIConvertPredictionsProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst client_polly_1 = require(\"@aws-sdk/client-polly\");\nconst client_translate_1 = require(\"@aws-sdk/client-translate\");\nconst eventstream_codec_1 = require(\"@smithy/eventstream-codec\");\nconst util_utf8_1 = require(\"@smithy/util-utf8\");\nconst buffer_1 = require(\"buffer\");\nconst validation_1 = require(\"../errors/types/validation\");\nconst assertValidationError_1 = require(\"../errors/utils/assertValidationError\");\nconst types_1 = require(\"../types\");\nconst logger = new core_1.ConsoleLogger('AmazonAIConvertPredictionsProvider');\nconst eventBuilder = new eventstream_codec_1.EventStreamCodec(util_utf8_1.toUtf8, util_utf8_1.fromUtf8);\nconst LANGUAGES_CODE_IN_8KHZ = ['fr-FR', 'en-AU', 'en-GB', 'fr-CA'];\nclass AmazonAIConvertPredictionsProvider {\n constructor() {\n this.inputSampleRate = 44100;\n }\n getProviderName() {\n return 'AmazonAIConvertPredictionsProvider';\n }\n convert(input) {\n (0, assertValidationError_1.assertValidationError)((0, types_1.isValidConvertInput)(input), validation_1.PredictionsValidationErrorCode.InvalidInput);\n if ((0, types_1.isTranslateTextInput)(input)) {\n logger.debug('translateText');\n return this.translateText(input);\n }\n else if ((0, types_1.isTextToSpeechInput)(input)) {\n logger.debug('textToSpeech');\n return this.convertTextToSpeech(input);\n }\n else {\n logger.debug('textToSpeech');\n return this.convertSpeechToText(input);\n }\n }\n async translateText(input) {\n logger.debug('Starting translation');\n const { translateText = {} } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!translateText.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults = {}, region } = translateText;\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { sourceLanguage, targetLanguage } = defaults;\n const sourceLanguageCode = input.translateText?.source?.language ?? sourceLanguage;\n const targetLanguageCode = input.translateText?.targetLanguage ?? targetLanguage;\n (0, assertValidationError_1.assertValidationError)(!!sourceLanguageCode, validation_1.PredictionsValidationErrorCode.NoSourceLanguage);\n (0, assertValidationError_1.assertValidationError)(!!targetLanguageCode, validation_1.PredictionsValidationErrorCode.NoTargetLanguage);\n this.translateClient = new client_translate_1.TranslateClient({\n region,\n credentials,\n customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Convert,\n }),\n });\n const translateTextCommand = new client_translate_1.TranslateTextCommand({\n SourceLanguageCode: sourceLanguageCode,\n TargetLanguageCode: targetLanguageCode,\n Text: input.translateText?.source?.text,\n });\n const data = await this.translateClient.send(translateTextCommand);\n return {\n text: data.TranslatedText,\n language: data.TargetLanguageCode,\n };\n }\n async convertTextToSpeech(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n (0, assertValidationError_1.assertValidationError)(!!input.textToSpeech?.source, validation_1.PredictionsValidationErrorCode.NoSource);\n const { speechGenerator } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!speechGenerator?.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults = {}, region } = speechGenerator;\n const { voiceId: defaultVoiceId } = defaults;\n const voiceId = input.textToSpeech?.voiceId ?? defaultVoiceId;\n (0, assertValidationError_1.assertValidationError)(!!voiceId, validation_1.PredictionsValidationErrorCode.NoVoiceId);\n this.pollyClient = new client_polly_1.PollyClient({\n region,\n credentials,\n customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Convert,\n }),\n });\n const synthesizeSpeechCommand = new client_polly_1.SynthesizeSpeechCommand({\n OutputFormat: 'mp3',\n Text: input.textToSpeech?.source?.text,\n VoiceId: voiceId,\n TextType: 'text',\n SampleRate: '24000',\n // tslint:disable-next-line: align\n });\n const data = await this.pollyClient.send(synthesizeSpeechCommand);\n const response = new Response(data.AudioStream);\n const arrayBuffer = await response.arrayBuffer();\n const blob = new Blob([arrayBuffer], {\n type: data.ContentType,\n });\n const url = URL.createObjectURL(blob);\n return {\n speech: { url },\n audioStream: arrayBuffer,\n text: input.textToSpeech?.source?.text,\n };\n }\n async convertSpeechToText(input) {\n logger.debug('starting transcription..');\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { transcription } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!transcription?.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults, region } = transcription;\n const language = input.transcription?.language ?? defaults?.language;\n (0, assertValidationError_1.assertValidationError)(!!language, validation_1.PredictionsValidationErrorCode.NoLanguage);\n const source = input.transcription?.source;\n (0, assertValidationError_1.assertValidationError)((0, types_1.isConvertBytesSource)(source), validation_1.PredictionsValidationErrorCode.InvalidSource);\n const connection = await this.openConnectionWithTranscribe({\n credentials,\n region,\n languageCode: language,\n });\n const fullText = await this.sendDataToTranscribe({\n connection,\n raw: source.bytes,\n languageCode: language,\n });\n return {\n transcription: {\n fullText,\n },\n };\n }\n static serializeDataFromTranscribe(message) {\n let decodedMessage = '';\n const transcribeMessage = eventBuilder.decode(buffer_1.Buffer.from(message.data));\n const transcribeMessageJson = JSON.parse((0, util_utf8_1.toUtf8)(transcribeMessage.body));\n if (transcribeMessage.headers[':message-type'].value === 'exception') {\n logger.debug('exception', JSON.stringify(transcribeMessageJson.Message, null, 2));\n throw new Error(transcribeMessageJson.Message);\n }\n else if (transcribeMessage.headers[':message-type'].value === 'event') {\n if (transcribeMessageJson.Transcript.Results.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].Alternatives.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].Alternatives[0]\n .Transcript.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].IsPartial === false) {\n decodedMessage =\n transcribeMessageJson.Transcript.Results[0].Alternatives[0]\n .Transcript + '\\n';\n logger.debug({ decodedMessage });\n }\n else {\n logger.debug({\n transcript: transcribeMessageJson.Transcript.Results[0].Alternatives[0],\n });\n }\n }\n }\n }\n }\n return decodedMessage;\n }\n sendDataToTranscribe({ connection, raw, languageCode, }) {\n return new Promise((res, rej) => {\n let fullText = '';\n connection.onmessage = message => {\n try {\n const decodedMessage = AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe(message);\n if (decodedMessage) {\n fullText += decodedMessage + ' ';\n }\n }\n catch (err) {\n logger.debug(err);\n rej(err);\n }\n };\n connection.onerror = errorEvent => {\n logger.debug({ errorEvent });\n rej('failed to transcribe, network error');\n };\n connection.onclose = closeEvent => {\n logger.debug({ closeEvent });\n return res(fullText.trim());\n };\n logger.debug({ raw });\n if (Array.isArray(raw)) {\n for (let i = 0; i < raw.length - 1023; i += 1024) {\n const data = raw.slice(i, i + 1024);\n this.sendEncodedDataToTranscribe(connection, data, languageCode);\n }\n }\n else {\n // If Buffer\n this.sendEncodedDataToTranscribe(connection, raw, languageCode);\n }\n // sending end frame\n const endFrameEventMessage = this.getAudioEventMessage(buffer_1.Buffer.from([]));\n const endFrameBinary = eventBuilder.encode(endFrameEventMessage);\n connection.send(endFrameBinary);\n });\n }\n sendEncodedDataToTranscribe(connection, data, languageCode) {\n const downsampledBuffer = this.downsampleBuffer({\n buffer: data,\n outputSampleRate: LANGUAGES_CODE_IN_8KHZ.includes(languageCode)\n ? 8000\n : 16000,\n });\n const pcmEncodedBuffer = this.pcmEncode(downsampledBuffer);\n const audioEventMessage = this.getAudioEventMessage(buffer_1.Buffer.from(pcmEncodedBuffer));\n const binary = eventBuilder.encode(audioEventMessage);\n connection.send(binary);\n }\n getAudioEventMessage(buffer) {\n const audioEventMessage = {\n body: buffer,\n headers: {\n ':message-type': {\n type: 'string',\n value: 'event',\n },\n ':event-type': {\n type: 'string',\n value: 'AudioEvent',\n },\n },\n };\n return audioEventMessage;\n }\n pcmEncode(input) {\n let offset = 0;\n // ArrayBuffer cannot be processed using length property\n if (input instanceof ArrayBuffer) {\n return input;\n }\n const buffer = new ArrayBuffer(input.length * 2);\n const view = new DataView(buffer);\n for (let i = 0; i < input.length; i++, offset += 2) {\n const s = Math.max(-1, Math.min(1, input[i]));\n view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);\n }\n return buffer;\n }\n downsampleBuffer({ buffer, outputSampleRate = 16000, }) {\n // Cannot process ArrayBuffer using length property\n if (outputSampleRate === this.inputSampleRate ||\n buffer instanceof ArrayBuffer) {\n return buffer;\n }\n const sampleRateRatio = this.inputSampleRate / outputSampleRate;\n const newLength = Math.round(buffer.length / sampleRateRatio);\n const result = new Float32Array(newLength);\n let offsetResult = 0;\n let offsetBuffer = 0;\n while (offsetResult < result.length) {\n const nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);\n let accum = 0, count = 0;\n for (let i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {\n accum += buffer[i];\n count++;\n }\n result[offsetResult] = accum / count;\n offsetResult++;\n offsetBuffer = nextOffsetBuffer;\n }\n return result;\n }\n openConnectionWithTranscribe({ credentials, region, languageCode, }) {\n return new Promise(async (res, rej) => {\n const signedUrl = this.generateTranscribeUrl({\n credentials,\n region,\n languageCode,\n });\n logger.debug('connecting...');\n const connection = new WebSocket(signedUrl);\n connection.binaryType = 'arraybuffer';\n connection.onopen = () => {\n logger.debug('connected');\n res(connection);\n };\n });\n }\n generateTranscribeUrl({ credentials: { accessKeyId, secretAccessKey, sessionToken }, region, languageCode, }) {\n const credentials = {\n access_key: accessKeyId,\n secret_key: secretAccessKey,\n session_token: sessionToken,\n };\n const url = [\n `wss://transcribestreaming.${region}.amazonaws.com:8443`,\n '/stream-transcription-websocket?',\n `media-encoding=pcm&`,\n `sample-rate=${LANGUAGES_CODE_IN_8KHZ.includes(languageCode) ? '8000' : '16000'}&`,\n `language-code=${languageCode}`,\n ].join('');\n const signedUrl = utils_1.Signer.signUrl(url, credentials, { region, service: 'transcribe' }, 300);\n return signedUrl;\n }\n}\nexports.AmazonAIConvertPredictionsProvider = AmazonAIConvertPredictionsProvider;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACpD;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACxD,MAAM,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAChE,MAAM,mBAAmB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACjE,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACnC,MAAM,YAAY,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC3D,MAAM,uBAAuB,GAAG,OAAO,CAAC,uCAAuC,CAAC,CAAC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AC;AACnB,QAAQ,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3G,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kCAAkC,GAAG,kCAAkC;;"}
1
+ {"version":3,"file":"AmazonAIConvertPredictionsProvider.js","sources":["../../../src/providers/AmazonAIConvertPredictionsProvider.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmazonAIConvertPredictionsProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst buffer_1 = require(\"buffer\");\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst client_polly_1 = require(\"@aws-sdk/client-polly\");\nconst client_translate_1 = require(\"@aws-sdk/client-translate\");\nconst eventstream_codec_1 = require(\"@smithy/eventstream-codec\");\nconst util_utf8_1 = require(\"@smithy/util-utf8\");\nconst validation_1 = require(\"../errors/types/validation\");\nconst assertValidationError_1 = require(\"../errors/utils/assertValidationError\");\nconst types_1 = require(\"../types\");\nconst logger = new core_1.ConsoleLogger('AmazonAIConvertPredictionsProvider');\nconst eventBuilder = new eventstream_codec_1.EventStreamCodec(util_utf8_1.toUtf8, util_utf8_1.fromUtf8);\nconst LANGUAGES_CODE_IN_8KHZ = ['fr-FR', 'en-AU', 'en-GB', 'fr-CA'];\nclass AmazonAIConvertPredictionsProvider {\n constructor() {\n this.inputSampleRate = 44100;\n }\n getProviderName() {\n return 'AmazonAIConvertPredictionsProvider';\n }\n convert(input) {\n (0, assertValidationError_1.assertValidationError)((0, types_1.isValidConvertInput)(input), validation_1.PredictionsValidationErrorCode.InvalidInput);\n if ((0, types_1.isTranslateTextInput)(input)) {\n logger.debug('translateText');\n return this.translateText(input);\n }\n else if ((0, types_1.isTextToSpeechInput)(input)) {\n logger.debug('textToSpeech');\n return this.convertTextToSpeech(input);\n }\n else {\n logger.debug('textToSpeech');\n return this.convertSpeechToText(input);\n }\n }\n async translateText(input) {\n logger.debug('Starting translation');\n const { translateText = {} } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!translateText.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults = {}, region } = translateText;\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { sourceLanguage, targetLanguage } = defaults;\n const sourceLanguageCode = input.translateText?.source?.language ?? sourceLanguage;\n const targetLanguageCode = input.translateText?.targetLanguage ?? targetLanguage;\n (0, assertValidationError_1.assertValidationError)(!!sourceLanguageCode, validation_1.PredictionsValidationErrorCode.NoSourceLanguage);\n (0, assertValidationError_1.assertValidationError)(!!targetLanguageCode, validation_1.PredictionsValidationErrorCode.NoTargetLanguage);\n this.translateClient = new client_translate_1.TranslateClient({\n region,\n credentials,\n customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Convert,\n }),\n });\n const translateTextCommand = new client_translate_1.TranslateTextCommand({\n SourceLanguageCode: sourceLanguageCode,\n TargetLanguageCode: targetLanguageCode,\n Text: input.translateText?.source?.text,\n });\n const data = await this.translateClient.send(translateTextCommand);\n return {\n text: data.TranslatedText,\n language: data.TargetLanguageCode,\n };\n }\n async convertTextToSpeech(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n (0, assertValidationError_1.assertValidationError)(!!input.textToSpeech?.source, validation_1.PredictionsValidationErrorCode.NoSource);\n const { speechGenerator } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!speechGenerator?.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults = {}, region } = speechGenerator;\n const { voiceId: defaultVoiceId } = defaults;\n const voiceId = input.textToSpeech?.voiceId ?? defaultVoiceId;\n (0, assertValidationError_1.assertValidationError)(!!voiceId, validation_1.PredictionsValidationErrorCode.NoVoiceId);\n this.pollyClient = new client_polly_1.PollyClient({\n region,\n credentials,\n customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Convert,\n }),\n });\n const synthesizeSpeechCommand = new client_polly_1.SynthesizeSpeechCommand({\n OutputFormat: 'mp3',\n Text: input.textToSpeech?.source?.text,\n VoiceId: voiceId,\n TextType: 'text',\n SampleRate: '24000',\n });\n const data = await this.pollyClient.send(synthesizeSpeechCommand);\n const response = new Response(data.AudioStream);\n const arrayBuffer = await response.arrayBuffer();\n const blob = new Blob([arrayBuffer], {\n type: data.ContentType,\n });\n const url = URL.createObjectURL(blob);\n return {\n speech: { url },\n audioStream: arrayBuffer,\n text: input.textToSpeech?.source?.text,\n };\n }\n async convertSpeechToText(input) {\n logger.debug('starting transcription..');\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { transcription } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!transcription?.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults, region } = transcription;\n const language = input.transcription?.language ?? defaults?.language;\n (0, assertValidationError_1.assertValidationError)(!!language, validation_1.PredictionsValidationErrorCode.NoLanguage);\n const source = input.transcription?.source;\n (0, assertValidationError_1.assertValidationError)((0, types_1.isConvertBytesSource)(source), validation_1.PredictionsValidationErrorCode.InvalidSource);\n const connection = await this.openConnectionWithTranscribe({\n credentials,\n region,\n languageCode: language,\n });\n const fullText = await this.sendDataToTranscribe({\n connection,\n raw: source.bytes,\n languageCode: language,\n });\n return {\n transcription: {\n fullText,\n },\n };\n }\n static serializeDataFromTranscribe(message) {\n let decodedMessage = '';\n const transcribeMessage = eventBuilder.decode(buffer_1.Buffer.from(message.data));\n const transcribeMessageJson = JSON.parse((0, util_utf8_1.toUtf8)(transcribeMessage.body));\n if (transcribeMessage.headers[':message-type'].value === 'exception') {\n logger.debug('exception', JSON.stringify(transcribeMessageJson.Message, null, 2));\n throw new Error(transcribeMessageJson.Message);\n }\n else if (transcribeMessage.headers[':message-type'].value === 'event') {\n if (transcribeMessageJson.Transcript.Results.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].Alternatives.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].Alternatives[0]\n .Transcript.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].IsPartial === false) {\n decodedMessage =\n transcribeMessageJson.Transcript.Results[0].Alternatives[0]\n .Transcript + '\\n';\n logger.debug({ decodedMessage });\n }\n else {\n logger.debug({\n transcript: transcribeMessageJson.Transcript.Results[0].Alternatives[0],\n });\n }\n }\n }\n }\n }\n return decodedMessage;\n }\n sendDataToTranscribe({ connection, raw, languageCode, }) {\n return new Promise((resolve, reject) => {\n let fullText = '';\n connection.onmessage = message => {\n try {\n const decodedMessage = AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe(message);\n if (decodedMessage) {\n fullText += decodedMessage + ' ';\n }\n }\n catch (err) {\n logger.debug(err);\n reject(err);\n }\n };\n connection.onerror = errorEvent => {\n logger.debug({ errorEvent });\n reject(new Error('failed to transcribe, network error'));\n };\n connection.onclose = closeEvent => {\n logger.debug({ closeEvent });\n resolve(fullText.trim());\n };\n logger.debug({ raw });\n if (Array.isArray(raw)) {\n for (let i = 0; i < raw.length - 1023; i += 1024) {\n const data = raw.slice(i, i + 1024);\n this.sendEncodedDataToTranscribe(connection, data, languageCode);\n }\n }\n else {\n // If Buffer\n this.sendEncodedDataToTranscribe(connection, raw, languageCode);\n }\n // sending end frame\n const endFrameEventMessage = this.getAudioEventMessage(buffer_1.Buffer.from([]));\n const endFrameBinary = eventBuilder.encode(endFrameEventMessage);\n connection.send(endFrameBinary);\n });\n }\n sendEncodedDataToTranscribe(connection, data, languageCode) {\n const downsampledBuffer = this.downsampleBuffer({\n buffer: data,\n outputSampleRate: LANGUAGES_CODE_IN_8KHZ.includes(languageCode)\n ? 8000\n : 16000,\n });\n const pcmEncodedBuffer = this.pcmEncode(downsampledBuffer);\n const audioEventMessage = this.getAudioEventMessage(buffer_1.Buffer.from(pcmEncodedBuffer));\n const binary = eventBuilder.encode(audioEventMessage);\n connection.send(binary);\n }\n getAudioEventMessage(buffer) {\n const audioEventMessage = {\n body: buffer,\n headers: {\n ':message-type': {\n type: 'string',\n value: 'event',\n },\n ':event-type': {\n type: 'string',\n value: 'AudioEvent',\n },\n },\n };\n return audioEventMessage;\n }\n pcmEncode(input) {\n let offset = 0;\n // ArrayBuffer cannot be processed using length property\n if (input instanceof ArrayBuffer) {\n return input;\n }\n const buffer = new ArrayBuffer(input.length * 2);\n const view = new DataView(buffer);\n for (let i = 0; i < input.length; i++, offset += 2) {\n const s = Math.max(-1, Math.min(1, input[i]));\n view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);\n }\n return buffer;\n }\n downsampleBuffer({ buffer, outputSampleRate = 16000, }) {\n // Cannot process ArrayBuffer using length property\n if (outputSampleRate === this.inputSampleRate ||\n buffer instanceof ArrayBuffer) {\n return buffer;\n }\n const sampleRateRatio = this.inputSampleRate / outputSampleRate;\n const newLength = Math.round(buffer.length / sampleRateRatio);\n const result = new Float32Array(newLength);\n let offsetResult = 0;\n let offsetBuffer = 0;\n while (offsetResult < result.length) {\n const nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);\n let accum = 0;\n let count = 0;\n for (let i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {\n accum += buffer[i];\n count++;\n }\n result[offsetResult] = accum / count;\n offsetResult++;\n offsetBuffer = nextOffsetBuffer;\n }\n return result;\n }\n openConnectionWithTranscribe({ credentials, region, languageCode, }) {\n return new Promise((resolve, _reject) => {\n const signedUrl = this.generateTranscribeUrl({\n credentials,\n region,\n languageCode,\n });\n logger.debug('connecting...');\n const connection = new WebSocket(signedUrl);\n connection.binaryType = 'arraybuffer';\n connection.onopen = () => {\n logger.debug('connected');\n resolve(connection);\n };\n });\n }\n generateTranscribeUrl({ credentials: { accessKeyId, secretAccessKey, sessionToken }, region, languageCode, }) {\n const credentials = {\n access_key: accessKeyId,\n secret_key: secretAccessKey,\n session_token: sessionToken,\n };\n const url = [\n `wss://transcribestreaming.${region}.amazonaws.com:8443`,\n '/stream-transcription-websocket?',\n `media-encoding=pcm&`,\n `sample-rate=${LANGUAGES_CODE_IN_8KHZ.includes(languageCode) ? '8000' : '16000'}&`,\n `language-code=${languageCode}`,\n ].join('');\n const signedUrl = utils_1.Signer.signUrl(url, credentials, { region, service: 'transcribe' }, 300);\n return signedUrl;\n }\n}\nexports.AmazonAIConvertPredictionsProvider = AmazonAIConvertPredictionsProvider;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACpD;AACA;AACA,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACnC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACxD,MAAM,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAChE,MAAM,mBAAmB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACjE,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAmB,C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CAAC,YAAY,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;AAC9F,YAAY,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;AAC3C,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnB,QAAQ,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3G,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kCAAkC,GAAG,kCAAkC;;"}
@@ -42,7 +42,7 @@ class AmazonAIIdentifyPredictionsProvider {
42
42
  * @return {Promise<Image>} - Promise resolving to the converted source object.
43
43
  */
44
44
  configureSource(source) {
45
- return new Promise((res, rej) => {
45
+ return new Promise((resolve, reject) => {
46
46
  if ((0, types_1.isStorageSource)(source)) {
47
47
  const storageConfig = {
48
48
  accessLevel: source.level,
@@ -53,40 +53,46 @@ class AmazonAIIdentifyPredictionsProvider {
53
53
  const parser = /https:\/\/([a-zA-Z0-9%\-_.]+)\.s3\.[A-Za-z0-9%\-._~]+\/([a-zA-Z0-9%\-._~/]+)\?/;
54
54
  const parsedURL = value.url.toString().match(parser) ?? '';
55
55
  if (parsedURL.length < 3)
56
- rej('Invalid S3 key was given.');
57
- res({
56
+ reject(new Error('Invalid S3 key was given.'));
57
+ resolve({
58
58
  S3Object: {
59
59
  Bucket: parsedURL[1],
60
60
  Name: decodeURIComponent(parsedURL[2]),
61
61
  },
62
62
  });
63
63
  })
64
- .catch(err => rej(err));
64
+ .catch(err => {
65
+ reject(err);
66
+ });
65
67
  }
66
68
  else if ((0, types_1.isFileSource)(source)) {
67
69
  (0, Utils_1.blobToArrayBuffer)(source.file)
68
70
  .then(buffer => {
69
- res({ Bytes: new Uint8Array(buffer) });
71
+ resolve({ Bytes: new Uint8Array(buffer) });
70
72
  })
71
- .catch(err => rej(err));
73
+ .catch(err => {
74
+ reject(err);
75
+ });
72
76
  }
73
77
  else if ((0, types_1.isIdentifyBytesSource)(source)) {
74
- const bytes = source.bytes;
78
+ const { bytes } = source;
75
79
  if (bytes instanceof Blob) {
76
80
  (0, Utils_1.blobToArrayBuffer)(bytes)
77
81
  .then(buffer => {
78
- res({ Bytes: new Uint8Array(buffer) });
82
+ resolve({ Bytes: new Uint8Array(buffer) });
79
83
  })
80
- .catch(err => rej(err));
84
+ .catch(err => {
85
+ reject(err);
86
+ });
81
87
  }
82
88
  if (bytes instanceof ArrayBuffer || bytes instanceof Buffer) {
83
- res({ Bytes: new Uint8Array(bytes) });
89
+ resolve({ Bytes: new Uint8Array(bytes) });
84
90
  }
85
91
  // everything else can be directly passed to Rekognition / Textract.
86
- res({ Bytes: bytes });
92
+ resolve({ Bytes: bytes });
87
93
  }
88
94
  else {
89
- rej('Input source is not configured correctly.');
95
+ reject(new Error('Input source is not configured correctly.'));
90
96
  }
91
97
  });
92
98
  }
@@ -112,8 +118,7 @@ class AmazonAIIdentifyPredictionsProvider {
112
118
  credentials,
113
119
  customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),
114
120
  });
115
- let inputDocument;
116
- inputDocument = await this.configureSource(input.text?.source);
121
+ const inputDocument = await this.configureSource(input.text?.source);
117
122
  // get default value if format isn't specified in the input.
118
123
  const format = input.text?.format ?? configFormat;
119
124
  const featureTypes = []; // structures we want to analyze (e.g. [TABLES, FORMS]).
@@ -195,8 +200,8 @@ class AmazonAIIdentifyPredictionsProvider {
195
200
  }
196
201
  /**
197
202
  * Calls Rekognition.detectLabels and organizes the returned data.
198
- * @param {DetectLabelsInput} param - parameter to be passed onto Rekognition
199
- * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to organized detectLabels response.
203
+ * @param param - parameters as {@link DetectLabelsCommandInput} to be passed onto Rekognition
204
+ * @return a promise resolving to organized detectLabels response as {@link IdentifyLabelsOutput}.
200
205
  */
201
206
  async detectLabels(param) {
202
207
  const detectLabelsCommand = new client_rekognition_1.DetectLabelsCommand(param);
@@ -218,8 +223,8 @@ class AmazonAIIdentifyPredictionsProvider {
218
223
  }
219
224
  /**
220
225
  * Calls Rekognition.detectModerationLabels and organizes the returned data.
221
- * @param {Rekognition.DetectLabelsRequest} param - Parameter to be passed onto Rekognition
222
- * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to organized detectModerationLabels response.
226
+ * @param param parameter to be passed onto Rekognition as {@link DetectModerationLabelsCommandInput}
227
+ * @return a promise resolving to organized detectModerationLabels response as {@link IdentifyLabelsOutput}.
223
228
  */
224
229
  async detectModerationLabels(param) {
225
230
  const detectModerationLabelsCommand = new client_rekognition_1.DetectModerationLabelsCommand(param);
@@ -234,8 +239,8 @@ class AmazonAIIdentifyPredictionsProvider {
234
239
  /**
235
240
  * Identify faces within an image that is provided as input, and match faces from a collection
236
241
  * or identify celebrities.
237
- * @param {IdentifyEntityInput} input - object containing the source image and face match options.
238
- * @return {Promise<IdentifyEntityOutput>} Promise resolving to identify results.
242
+ * @param input - object of {@link IdentifyEntitiesInput} containing the source image and face match options.
243
+ * @return a promise resolving to identify results as {@link IdentifyEntitiesOutput}.
239
244
  */
240
245
  async identifyEntities(input) {
241
246
  const { credentials } = await (0, core_1.fetchAuthSession)();
@@ -1 +1 @@
1
- {"version":3,"file":"AmazonAIIdentifyPredictionsProvider.js","sources":["../../../src/providers/AmazonAIIdentifyPredictionsProvider.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmazonAIIdentifyPredictionsProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst storage_1 = require(\"@aws-amplify/storage\");\nconst client_rekognition_1 = require(\"@aws-sdk/client-rekognition\");\nconst client_textract_1 = require(\"@aws-sdk/client-textract\");\nconst validation_1 = require(\"../errors/types/validation\");\nconst assertValidationError_1 = require(\"../errors/utils/assertValidationError\");\nconst types_1 = require(\"../types\");\nconst IdentifyTextUtils_1 = require(\"./IdentifyTextUtils\");\nconst Utils_1 = require(\"./Utils\");\nconst logger = new core_1.ConsoleLogger('AmazonAIIdentifyPredictionsProvider');\nclass AmazonAIIdentifyPredictionsProvider {\n getProviderName() {\n return 'AmazonAIIdentifyPredictionsProvider';\n }\n identify(input) {\n (0, assertValidationError_1.assertValidationError)((0, types_1.isValidIdentifyInput)(input), validation_1.PredictionsValidationErrorCode.InvalidInput);\n if ((0, types_1.isIdentifyTextInput)(input)) {\n logger.debug('identifyText');\n return this.identifyText(input);\n }\n else if ((0, types_1.isIdentifyLabelsInput)(input)) {\n logger.debug('identifyLabels');\n return this.identifyLabels(input);\n }\n else {\n logger.debug('identifyEntities');\n return this.identifyEntities(input);\n }\n }\n /**\n * Verify user input source and converts it into source object readable by Rekognition and Textract.\n * Note that Rekognition and Textract use the same source interface, so we need not worry about types.\n * @param {IdentifySource} source - User input source that directs to the object user wants\n * to identify (storage, file, or bytes).\n * @return {Promise<Image>} - Promise resolving to the converted source object.\n */\n configureSource(source) {\n return new Promise((res, rej) => {\n if ((0, types_1.isStorageSource)(source)) {\n const storageConfig = {\n accessLevel: source.level,\n targetIdentityId: source.identityId,\n };\n (0, storage_1.getUrl)({ key: source.key, options: storageConfig })\n .then(value => {\n const parser = /https:\\/\\/([a-zA-Z0-9%\\-_.]+)\\.s3\\.[A-Za-z0-9%\\-._~]+\\/([a-zA-Z0-9%\\-._~/]+)\\?/;\n const parsedURL = value.url.toString().match(parser) ?? '';\n if (parsedURL.length < 3)\n rej('Invalid S3 key was given.');\n res({\n S3Object: {\n Bucket: parsedURL[1],\n Name: decodeURIComponent(parsedURL[2]),\n },\n });\n })\n .catch(err => rej(err));\n }\n else if ((0, types_1.isFileSource)(source)) {\n (0, Utils_1.blobToArrayBuffer)(source.file)\n .then(buffer => {\n res({ Bytes: new Uint8Array(buffer) });\n })\n .catch(err => rej(err));\n }\n else if ((0, types_1.isIdentifyBytesSource)(source)) {\n const bytes = source.bytes;\n if (bytes instanceof Blob) {\n (0, Utils_1.blobToArrayBuffer)(bytes)\n .then(buffer => {\n res({ Bytes: new Uint8Array(buffer) });\n })\n .catch(err => rej(err));\n }\n if (bytes instanceof ArrayBuffer || bytes instanceof Buffer) {\n res({ Bytes: new Uint8Array(bytes) });\n }\n // everything else can be directly passed to Rekognition / Textract.\n res({ Bytes: bytes });\n }\n else {\n rej('Input source is not configured correctly.');\n }\n });\n }\n /**\n * Recognize text from real-world images and documents (plain text, forms and tables). Detects text in the input\n * image and converts it into machine-readable text.\n * @param {IdentifySource} source - Object containing the source image and feature types to analyze.\n * @return {Promise<IdentifyTextOutput>} - Promise resolving to object containing identified texts.\n */\n async identifyText(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyText = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', defaults = {} } = identifyText;\n const { format: configFormat = 'PLAIN' } = defaults;\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n this.textractClient = new client_textract_1.TextractClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n let inputDocument;\n inputDocument = await this.configureSource(input.text?.source);\n // get default value if format isn't specified in the input.\n const format = input.text?.format ?? configFormat;\n const featureTypes = []; // structures we want to analyze (e.g. [TABLES, FORMS]).\n if (format === 'FORM' || format === 'ALL')\n featureTypes.push('FORMS');\n if (format === 'TABLE' || format === 'ALL')\n featureTypes.push('TABLES');\n if (featureTypes.length === 0) {\n /**\n * Empty featureTypes indicates that we will identify plain text. We will use rekognition (suitable\n * for everyday images but has 50 word limit) first and see if reaches its word limit. If it does, then\n * we call textract and use the data that identify more words.\n */\n const textractParam = {\n Document: inputDocument,\n };\n const rekognitionParam = {\n Image: inputDocument,\n };\n const detectTextCommand = new client_rekognition_1.DetectTextCommand(rekognitionParam);\n const rekognitionData = await this.rekognitionClient.send(detectTextCommand);\n const rekognitionResponse = (0, IdentifyTextUtils_1.categorizeRekognitionBlocks)(rekognitionData.TextDetections);\n if (rekognitionResponse.text.words.length < 50) {\n // did not hit the word limit, return the data\n return rekognitionResponse;\n }\n const detectDocumentTextCommand = new client_textract_1.DetectDocumentTextCommand(textractParam);\n const { Blocks } = await this.textractClient.send(detectDocumentTextCommand);\n if ((rekognitionData.TextDetections?.length ?? 0) > (Blocks?.length ?? 0)) {\n return rekognitionResponse;\n }\n return (0, IdentifyTextUtils_1.categorizeTextractBlocks)(Blocks);\n }\n else {\n const param = {\n Document: inputDocument,\n FeatureTypes: featureTypes,\n };\n const analyzeDocumentCommand = new client_textract_1.AnalyzeDocumentCommand(param);\n const { Blocks } = await this.textractClient.send(analyzeDocumentCommand);\n return (0, IdentifyTextUtils_1.categorizeTextractBlocks)(Blocks);\n }\n }\n /**\n * Identify instances of real world entities from an image and if it contains unsafe content.\n * @param {IdentifyLabelsInput} input - Object containing the source image and entity type to identify.\n * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to an array of identified entities.\n */\n async identifyLabels(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyLabels = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', defaults = {} } = identifyLabels;\n const { type = 'LABELS' } = defaults;\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n const inputImage = await this.configureSource(input.labels?.source);\n const param = { Image: inputImage };\n const servicePromises = [];\n // get default argument\n const entityType = input.labels?.type ?? type;\n if (entityType === 'LABELS' || entityType === 'ALL') {\n servicePromises.push(this.detectLabels(param));\n }\n if (entityType === 'UNSAFE' || entityType === 'ALL') {\n servicePromises.push(this.detectModerationLabels(param));\n }\n return Promise.all(servicePromises).then(data => {\n let identifyResult = {};\n // concatenate resolved promises to a single object\n data.forEach(val => {\n identifyResult = { ...identifyResult, ...val };\n });\n return identifyResult;\n });\n }\n /**\n * Calls Rekognition.detectLabels and organizes the returned data.\n * @param {DetectLabelsInput} param - parameter to be passed onto Rekognition\n * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to organized detectLabels response.\n */\n async detectLabels(param) {\n const detectLabelsCommand = new client_rekognition_1.DetectLabelsCommand(param);\n const data = await this.rekognitionClient.send(detectLabelsCommand);\n if (!data.Labels)\n return {}; // no image was detected\n const detectLabelData = data.Labels.map(label => {\n const boxes = label.Instances?.map(instance => (0, Utils_1.makeCamelCase)(instance.BoundingBox)) || [];\n return {\n name: label.Name,\n boundingBoxes: boxes,\n metadata: {\n confidence: label.Confidence,\n parents: (0, Utils_1.makeCamelCaseArray)(label.Parents),\n },\n };\n });\n return { labels: detectLabelData };\n }\n /**\n * Calls Rekognition.detectModerationLabels and organizes the returned data.\n * @param {Rekognition.DetectLabelsRequest} param - Parameter to be passed onto Rekognition\n * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to organized detectModerationLabels response.\n */\n async detectModerationLabels(param) {\n const detectModerationLabelsCommand = new client_rekognition_1.DetectModerationLabelsCommand(param);\n const data = await this.rekognitionClient.send(detectModerationLabelsCommand);\n if (data.ModerationLabels?.length !== 0) {\n return { unsafe: 'YES' };\n }\n else {\n return { unsafe: 'NO' };\n }\n }\n /**\n * Identify faces within an image that is provided as input, and match faces from a collection\n * or identify celebrities.\n * @param {IdentifyEntityInput} input - object containing the source image and face match options.\n * @return {Promise<IdentifyEntityOutput>} Promise resolving to identify results.\n */\n async identifyEntities(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyEntities = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', celebrityDetectionEnabled = false, defaults = {}, } = identifyEntities;\n const { collectionId: collectionIdConfig = '', maxEntities: maxFacesConfig = 50, } = defaults;\n // default arguments\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n const inputImage = await this.configureSource(input.entities?.source);\n const param = { Attributes: ['ALL'], Image: inputImage };\n if ((0, types_1.isIdentifyCelebrities)(input.entities) &&\n input.entities.celebrityDetection) {\n (0, assertValidationError_1.assertValidationError)(celebrityDetectionEnabled, validation_1.PredictionsValidationErrorCode.CelebrityDetectionNotEnabled);\n const recognizeCelebritiesCommand = new client_rekognition_1.RecognizeCelebritiesCommand(param);\n const data = await this.rekognitionClient.send(recognizeCelebritiesCommand);\n const faces = data.CelebrityFaces?.map(celebrity => ({\n boundingBox: (0, Utils_1.makeCamelCase)(celebrity.Face?.BoundingBox),\n landmarks: (0, Utils_1.makeCamelCaseArray)(celebrity.Face?.Landmarks),\n metadata: {\n ...(0, Utils_1.makeCamelCase)(celebrity, ['Id', 'Name', 'Urls']),\n pose: (0, Utils_1.makeCamelCase)(celebrity.Face?.Pose),\n },\n })) ?? [];\n return { entities: faces };\n }\n else if ((0, types_1.isIdentifyFromCollection)(input.entities) &&\n input.entities.collection) {\n const { collectionId = collectionIdConfig, maxEntities: maxFaces = maxFacesConfig, } = input.entities;\n // Concatenate additional parameters\n const updatedParam = {\n ...param,\n CollectionId: collectionId,\n MaxFaces: maxFaces,\n };\n const searchFacesByImageCommand = new client_rekognition_1.SearchFacesByImageCommand(updatedParam);\n const data = await this.rekognitionClient.send(searchFacesByImageCommand);\n const faces = data.FaceMatches?.map(match => {\n const externalImageId = match.Face?.ExternalImageId\n ? this.decodeExternalImageId(match.Face.ExternalImageId)\n : undefined;\n return {\n boundingBox: (0, Utils_1.makeCamelCase)(match.Face?.BoundingBox),\n metadata: {\n externalImageId,\n similarity: match.Similarity,\n },\n };\n }) ?? [];\n return { entities: faces };\n }\n else {\n const detectFacesCommand = new client_rekognition_1.DetectFacesCommand(param);\n const data = await this.rekognitionClient.send(detectFacesCommand);\n const faces = data.FaceDetails?.map(detail => {\n // face attributes keys we want to extract from Rekognition's response\n const attributeKeys = [\n 'Smile',\n 'Eyeglasses',\n 'Sunglasses',\n 'Gender',\n 'Beard',\n 'Mustache',\n 'EyesOpen',\n 'MouthOpen',\n ];\n const faceAttributes = (0, Utils_1.makeCamelCase)(detail, attributeKeys);\n faceAttributes.emotions = detail.Emotions?.map(emotion => emotion.Type);\n return {\n boundingBox: (0, Utils_1.makeCamelCase)(detail.BoundingBox),\n landmarks: (0, Utils_1.makeCamelCaseArray)(detail.Landmarks),\n ageRange: (0, Utils_1.makeCamelCase)(detail.AgeRange),\n attributes: faceAttributes,\n metadata: {\n confidence: detail.Confidence,\n pose: (0, Utils_1.makeCamelCase)(detail.Pose),\n },\n };\n }) ?? [];\n return { entities: faces };\n }\n }\n decodeExternalImageId(externalImageId) {\n return ('' + externalImageId).replace(/::/g, '/');\n }\n}\nexports.AmazonAIIdentifyPredictionsProvider = AmazonAIIdentifyPredictionsProvider;\nfunction _getPredictionsIdentifyAmplifyUserAgent() {\n return (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Identify,\n });\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mCAAmC,GAAG,KAAK,CAAC,CAAC;AACrD;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC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\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmazonAIIdentifyPredictionsProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst storage_1 = require(\"@aws-amplify/storage\");\nconst client_rekognition_1 = require(\"@aws-sdk/client-rekognition\");\nconst client_textract_1 = require(\"@aws-sdk/client-textract\");\nconst validation_1 = require(\"../errors/types/validation\");\nconst assertValidationError_1 = require(\"../errors/utils/assertValidationError\");\nconst types_1 = require(\"../types\");\nconst IdentifyTextUtils_1 = require(\"./IdentifyTextUtils\");\nconst Utils_1 = require(\"./Utils\");\nconst logger = new core_1.ConsoleLogger('AmazonAIIdentifyPredictionsProvider');\nclass AmazonAIIdentifyPredictionsProvider {\n getProviderName() {\n return 'AmazonAIIdentifyPredictionsProvider';\n }\n identify(input) {\n (0, assertValidationError_1.assertValidationError)((0, types_1.isValidIdentifyInput)(input), validation_1.PredictionsValidationErrorCode.InvalidInput);\n if ((0, types_1.isIdentifyTextInput)(input)) {\n logger.debug('identifyText');\n return this.identifyText(input);\n }\n else if ((0, types_1.isIdentifyLabelsInput)(input)) {\n logger.debug('identifyLabels');\n return this.identifyLabels(input);\n }\n else {\n logger.debug('identifyEntities');\n return this.identifyEntities(input);\n }\n }\n /**\n * Verify user input source and converts it into source object readable by Rekognition and Textract.\n * Note that Rekognition and Textract use the same source interface, so we need not worry about types.\n * @param {IdentifySource} source - User input source that directs to the object user wants\n * to identify (storage, file, or bytes).\n * @return {Promise<Image>} - Promise resolving to the converted source object.\n */\n configureSource(source) {\n return new Promise((resolve, reject) => {\n if ((0, types_1.isStorageSource)(source)) {\n const storageConfig = {\n accessLevel: source.level,\n targetIdentityId: source.identityId,\n };\n (0, storage_1.getUrl)({ key: source.key, options: storageConfig })\n .then(value => {\n const parser = /https:\\/\\/([a-zA-Z0-9%\\-_.]+)\\.s3\\.[A-Za-z0-9%\\-._~]+\\/([a-zA-Z0-9%\\-._~/]+)\\?/;\n const parsedURL = value.url.toString().match(parser) ?? '';\n if (parsedURL.length < 3)\n reject(new Error('Invalid S3 key was given.'));\n resolve({\n S3Object: {\n Bucket: parsedURL[1],\n Name: decodeURIComponent(parsedURL[2]),\n },\n });\n })\n .catch(err => {\n reject(err);\n });\n }\n else if ((0, types_1.isFileSource)(source)) {\n (0, Utils_1.blobToArrayBuffer)(source.file)\n .then(buffer => {\n resolve({ Bytes: new Uint8Array(buffer) });\n })\n .catch(err => {\n reject(err);\n });\n }\n else if ((0, types_1.isIdentifyBytesSource)(source)) {\n const { bytes } = source;\n if (bytes instanceof Blob) {\n (0, Utils_1.blobToArrayBuffer)(bytes)\n .then(buffer => {\n resolve({ Bytes: new Uint8Array(buffer) });\n })\n .catch(err => {\n reject(err);\n });\n }\n if (bytes instanceof ArrayBuffer || bytes instanceof Buffer) {\n resolve({ Bytes: new Uint8Array(bytes) });\n }\n // everything else can be directly passed to Rekognition / Textract.\n resolve({ Bytes: bytes });\n }\n else {\n reject(new Error('Input source is not configured correctly.'));\n }\n });\n }\n /**\n * Recognize text from real-world images and documents (plain text, forms and tables). Detects text in the input\n * image and converts it into machine-readable text.\n * @param {IdentifySource} source - Object containing the source image and feature types to analyze.\n * @return {Promise<IdentifyTextOutput>} - Promise resolving to object containing identified texts.\n */\n async identifyText(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyText = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', defaults = {} } = identifyText;\n const { format: configFormat = 'PLAIN' } = defaults;\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n this.textractClient = new client_textract_1.TextractClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n const inputDocument = await this.configureSource(input.text?.source);\n // get default value if format isn't specified in the input.\n const format = input.text?.format ?? configFormat;\n const featureTypes = []; // structures we want to analyze (e.g. [TABLES, FORMS]).\n if (format === 'FORM' || format === 'ALL')\n featureTypes.push('FORMS');\n if (format === 'TABLE' || format === 'ALL')\n featureTypes.push('TABLES');\n if (featureTypes.length === 0) {\n /**\n * Empty featureTypes indicates that we will identify plain text. We will use rekognition (suitable\n * for everyday images but has 50 word limit) first and see if reaches its word limit. If it does, then\n * we call textract and use the data that identify more words.\n */\n const textractParam = {\n Document: inputDocument,\n };\n const rekognitionParam = {\n Image: inputDocument,\n };\n const detectTextCommand = new client_rekognition_1.DetectTextCommand(rekognitionParam);\n const rekognitionData = await this.rekognitionClient.send(detectTextCommand);\n const rekognitionResponse = (0, IdentifyTextUtils_1.categorizeRekognitionBlocks)(rekognitionData.TextDetections);\n if (rekognitionResponse.text.words.length < 50) {\n // did not hit the word limit, return the data\n return rekognitionResponse;\n }\n const detectDocumentTextCommand = new client_textract_1.DetectDocumentTextCommand(textractParam);\n const { Blocks } = await this.textractClient.send(detectDocumentTextCommand);\n if ((rekognitionData.TextDetections?.length ?? 0) > (Blocks?.length ?? 0)) {\n return rekognitionResponse;\n }\n return (0, IdentifyTextUtils_1.categorizeTextractBlocks)(Blocks);\n }\n else {\n const param = {\n Document: inputDocument,\n FeatureTypes: featureTypes,\n };\n const analyzeDocumentCommand = new client_textract_1.AnalyzeDocumentCommand(param);\n const { Blocks } = await this.textractClient.send(analyzeDocumentCommand);\n return (0, IdentifyTextUtils_1.categorizeTextractBlocks)(Blocks);\n }\n }\n /**\n * Identify instances of real world entities from an image and if it contains unsafe content.\n * @param {IdentifyLabelsInput} input - Object containing the source image and entity type to identify.\n * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to an array of identified entities.\n */\n async identifyLabels(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyLabels = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', defaults = {} } = identifyLabels;\n const { type = 'LABELS' } = defaults;\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n const inputImage = await this.configureSource(input.labels?.source);\n const param = { Image: inputImage };\n const servicePromises = [];\n // get default argument\n const entityType = input.labels?.type ?? type;\n if (entityType === 'LABELS' || entityType === 'ALL') {\n servicePromises.push(this.detectLabels(param));\n }\n if (entityType === 'UNSAFE' || entityType === 'ALL') {\n servicePromises.push(this.detectModerationLabels(param));\n }\n return Promise.all(servicePromises).then(data => {\n let identifyResult = {};\n // concatenate resolved promises to a single object\n data.forEach(val => {\n identifyResult = { ...identifyResult, ...val };\n });\n return identifyResult;\n });\n }\n /**\n * Calls Rekognition.detectLabels and organizes the returned data.\n * @param param - parameters as {@link DetectLabelsCommandInput} to be passed onto Rekognition\n * @return a promise resolving to organized detectLabels response as {@link IdentifyLabelsOutput}.\n */\n async detectLabels(param) {\n const detectLabelsCommand = new client_rekognition_1.DetectLabelsCommand(param);\n const data = await this.rekognitionClient.send(detectLabelsCommand);\n if (!data.Labels)\n return {}; // no image was detected\n const detectLabelData = data.Labels.map(label => {\n const boxes = label.Instances?.map(instance => (0, Utils_1.makeCamelCase)(instance.BoundingBox)) || [];\n return {\n name: label.Name,\n boundingBoxes: boxes,\n metadata: {\n confidence: label.Confidence,\n parents: (0, Utils_1.makeCamelCaseArray)(label.Parents),\n },\n };\n });\n return { labels: detectLabelData };\n }\n /**\n * Calls Rekognition.detectModerationLabels and organizes the returned data.\n * @param param parameter to be passed onto Rekognition as {@link DetectModerationLabelsCommandInput}\n * @return a promise resolving to organized detectModerationLabels response as {@link IdentifyLabelsOutput}.\n */\n async detectModerationLabels(param) {\n const detectModerationLabelsCommand = new client_rekognition_1.DetectModerationLabelsCommand(param);\n const data = await this.rekognitionClient.send(detectModerationLabelsCommand);\n if (data.ModerationLabels?.length !== 0) {\n return { unsafe: 'YES' };\n }\n else {\n return { unsafe: 'NO' };\n }\n }\n /**\n * Identify faces within an image that is provided as input, and match faces from a collection\n * or identify celebrities.\n * @param input - object of {@link IdentifyEntitiesInput} containing the source image and face match options.\n * @return a promise resolving to identify results as {@link IdentifyEntitiesOutput}.\n */\n async identifyEntities(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyEntities = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', celebrityDetectionEnabled = false, defaults = {}, } = identifyEntities;\n const { collectionId: collectionIdConfig = '', maxEntities: maxFacesConfig = 50, } = defaults;\n // default arguments\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n const inputImage = await this.configureSource(input.entities?.source);\n const param = { Attributes: ['ALL'], Image: inputImage };\n if ((0, types_1.isIdentifyCelebrities)(input.entities) &&\n input.entities.celebrityDetection) {\n (0, assertValidationError_1.assertValidationError)(celebrityDetectionEnabled, validation_1.PredictionsValidationErrorCode.CelebrityDetectionNotEnabled);\n const recognizeCelebritiesCommand = new client_rekognition_1.RecognizeCelebritiesCommand(param);\n const data = await this.rekognitionClient.send(recognizeCelebritiesCommand);\n const faces = data.CelebrityFaces?.map(celebrity => ({\n boundingBox: (0, Utils_1.makeCamelCase)(celebrity.Face?.BoundingBox),\n landmarks: (0, Utils_1.makeCamelCaseArray)(celebrity.Face?.Landmarks),\n metadata: {\n ...(0, Utils_1.makeCamelCase)(celebrity, ['Id', 'Name', 'Urls']),\n pose: (0, Utils_1.makeCamelCase)(celebrity.Face?.Pose),\n },\n })) ?? [];\n return { entities: faces };\n }\n else if ((0, types_1.isIdentifyFromCollection)(input.entities) &&\n input.entities.collection) {\n const { collectionId = collectionIdConfig, maxEntities: maxFaces = maxFacesConfig, } = input.entities;\n // Concatenate additional parameters\n const updatedParam = {\n ...param,\n CollectionId: collectionId,\n MaxFaces: maxFaces,\n };\n const searchFacesByImageCommand = new client_rekognition_1.SearchFacesByImageCommand(updatedParam);\n const data = await this.rekognitionClient.send(searchFacesByImageCommand);\n const faces = data.FaceMatches?.map(match => {\n const externalImageId = match.Face?.ExternalImageId\n ? this.decodeExternalImageId(match.Face.ExternalImageId)\n : undefined;\n return {\n boundingBox: (0, Utils_1.makeCamelCase)(match.Face?.BoundingBox),\n metadata: {\n externalImageId,\n similarity: match.Similarity,\n },\n };\n }) ?? [];\n return { entities: faces };\n }\n else {\n const detectFacesCommand = new client_rekognition_1.DetectFacesCommand(param);\n const data = await this.rekognitionClient.send(detectFacesCommand);\n const faces = data.FaceDetails?.map(detail => {\n // face attributes keys we want to extract from Rekognition's response\n const attributeKeys = [\n 'Smile',\n 'Eyeglasses',\n 'Sunglasses',\n 'Gender',\n 'Beard',\n 'Mustache',\n 'EyesOpen',\n 'MouthOpen',\n ];\n const faceAttributes = (0, Utils_1.makeCamelCase)(detail, attributeKeys);\n faceAttributes.emotions = detail.Emotions?.map(emotion => emotion.Type);\n return {\n boundingBox: (0, Utils_1.makeCamelCase)(detail.BoundingBox),\n landmarks: (0, Utils_1.makeCamelCaseArray)(detail.Landmarks),\n ageRange: (0, Utils_1.makeCamelCase)(detail.AgeRange),\n attributes: faceAttributes,\n metadata: {\n confidence: detail.Confidence,\n pose: (0, Utils_1.makeCamelCase)(detail.Pose),\n },\n };\n }) ?? [];\n return { entities: faces };\n }\n }\n decodeExternalImageId(externalImageId) {\n return ('' + externalImageId).replace(/::/g, '/');\n }\n}\nexports.AmazonAIIdentifyPredictionsProvider = AmazonAIIdentifyPredictionsProvider;\nfunction _getPredictionsIdentifyAmplifyUserAgent() {\n return (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Identify,\n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,CAAC,EAAE,GAAG,eAAe,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC1D,KAAK;AACL,CAAC;AACD,OAAO,CAAC,mCAAmC,GAAG,mCAAmC,CAAC;AAClF,SAAS,uCAAuC,GAAG;AACnD,IAAI,OAAO,IAAI,OAAO,CAAC,yBAAyB,EAAE;AAClD,QAAQ,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW;AAC9C,QAAQ,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ;AAClD,KAAK,CAAC,CAAC;AACP;;"}
@@ -27,9 +27,9 @@ class AmazonAIInterpretPredictionsProvider {
27
27
  const { text: textSource } = input;
28
28
  const { source, type = defaultType } = textSource;
29
29
  const { text } = source;
30
- let language;
30
+ let sourceLanguage;
31
31
  if ((0, types_1.isInterpretTextOthers)(textSource)) {
32
- language = textSource.source.language;
32
+ sourceLanguage = textSource.source.language;
33
33
  }
34
34
  this.comprehendClient = new client_comprehend_1.ComprehendClient({
35
35
  credentials,
@@ -40,7 +40,7 @@ class AmazonAIInterpretPredictionsProvider {
40
40
  }),
41
41
  });
42
42
  const doAll = type === 'all';
43
- let languageCode = language;
43
+ let languageCode = sourceLanguage;
44
44
  if (doAll || type === 'language') {
45
45
  const languageDetectionParams = {
46
46
  Text: text,
@@ -103,8 +103,8 @@ class AmazonAIInterpretPredictionsProvider {
103
103
  try {
104
104
  const detectKeyPhrasesCommand = new client_comprehend_1.DetectKeyPhrasesCommand(params);
105
105
  const data = await this.comprehendClient.send(detectKeyPhrasesCommand);
106
- const { KeyPhrases = [] } = data || {};
107
- return KeyPhrases.map(({ Text: text }) => {
106
+ const { KeyPhrases: keyPhrases = [] } = data || {};
107
+ return keyPhrases.map(({ Text: text }) => {
108
108
  return { text };
109
109
  });
110
110
  }
@@ -148,7 +148,7 @@ class AmazonAIInterpretPredictionsProvider {
148
148
  try {
149
149
  const detectSentimentCommand = new client_comprehend_1.DetectSentimentCommand(params);
150
150
  const data = await this.comprehendClient.send(detectSentimentCommand);
151
- const { Sentiment: predominant = '', SentimentScore: { Positive: positive = 0, Negative: negative = 0, Neutral: neutral = 0, Mixed: mixed = 0, } = {}, } = ({} = data);
151
+ const { Sentiment: predominant = '', SentimentScore: { Positive: positive = 0, Negative: negative = 0, Neutral: neutral = 0, Mixed: mixed = 0, } = {}, } = data ?? {};
152
152
  return { predominant, positive, negative, neutral, mixed };
153
153
  }
154
154
  catch (err) {
@@ -191,7 +191,7 @@ class AmazonAIInterpretPredictionsProvider {
191
191
  try {
192
192
  const detectDominantLanguageCommand = new client_comprehend_1.DetectDominantLanguageCommand(params);
193
193
  const data = await this.comprehendClient.send(detectDominantLanguageCommand);
194
- const { Languages: [{ LanguageCode }] = [{}] } = ({} = data || {});
194
+ const { Languages: [{ LanguageCode }] = [{ LanguageCode: undefined }] } = data ?? {};
195
195
  (0, assertValidationError_1.assertValidationError)(!!LanguageCode, validation_1.PredictionsValidationErrorCode.NoLanguage);
196
196
  return LanguageCode;
197
197
  }