@aws-amplify/predictions 6.0.1-console-preview.d745d43.0 → 6.0.1-mjs-test.20ead30.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.
Files changed (104) hide show
  1. package/{lib → dist/cjs}/Predictions.js +17 -16
  2. package/dist/cjs/Predictions.js.map +1 -0
  3. package/dist/cjs/errors/PredictionsError.js +17 -0
  4. package/dist/cjs/errors/PredictionsError.js.map +1 -0
  5. package/{lib → dist/cjs}/errors/types/validation.js +15 -14
  6. package/dist/cjs/errors/types/validation.js.map +1 -0
  7. package/dist/cjs/errors/utils/assertValidationError.js +16 -0
  8. package/dist/cjs/errors/utils/assertValidationError.js.map +1 -0
  9. package/{lib → dist/cjs}/index.js +3 -1
  10. package/dist/cjs/index.js.map +1 -0
  11. package/dist/cjs/providers/AmazonAIConvertPredictionsProvider.js +309 -0
  12. package/dist/cjs/providers/AmazonAIConvertPredictionsProvider.js.map +1 -0
  13. package/dist/cjs/providers/AmazonAIIdentifyPredictionsProvider.js +336 -0
  14. package/dist/cjs/providers/AmazonAIIdentifyPredictionsProvider.js.map +1 -0
  15. package/dist/cjs/providers/AmazonAIInterpretPredictionsProvider.js +210 -0
  16. package/dist/cjs/providers/AmazonAIInterpretPredictionsProvider.js.map +1 -0
  17. package/{lib → dist/cjs}/providers/IdentifyTextUtils.js +76 -141
  18. package/dist/cjs/providers/IdentifyTextUtils.js.map +1 -0
  19. package/{lib → dist/cjs}/providers/Utils.js +13 -12
  20. package/dist/cjs/providers/Utils.js.map +1 -0
  21. package/{lib → dist/cjs}/providers/index.js +6 -4
  22. package/dist/cjs/providers/index.js.map +1 -0
  23. package/{lib → dist/cjs}/types/AWSTypes.js +3 -1
  24. package/dist/cjs/types/AWSTypes.js.map +1 -0
  25. package/{lib → dist/cjs}/types/Predictions.js +17 -15
  26. package/dist/cjs/types/Predictions.js.map +1 -0
  27. package/{lib → dist/cjs}/types/index.js +4 -2
  28. package/dist/cjs/types/index.js.map +1 -0
  29. package/dist/esm/Predictions.mjs +31 -0
  30. package/dist/esm/Predictions.mjs.map +1 -0
  31. package/dist/esm/errors/PredictionsError.mjs +15 -0
  32. package/dist/esm/errors/PredictionsError.mjs.map +1 -0
  33. package/{lib-esm/errors/types/validation.js → dist/esm/errors/types/validation.mjs} +16 -14
  34. package/dist/esm/errors/types/validation.mjs.map +1 -0
  35. package/dist/esm/errors/utils/assertValidationError.mjs +14 -0
  36. package/dist/esm/errors/utils/assertValidationError.mjs.map +1 -0
  37. package/dist/esm/index.mjs +2 -0
  38. package/dist/esm/index.mjs.map +1 -0
  39. package/dist/esm/providers/AmazonAIConvertPredictionsProvider.mjs +307 -0
  40. package/dist/esm/providers/AmazonAIConvertPredictionsProvider.mjs.map +1 -0
  41. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.mjs +334 -0
  42. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.mjs.map +1 -0
  43. package/dist/esm/providers/AmazonAIInterpretPredictionsProvider.mjs +208 -0
  44. package/dist/esm/providers/AmazonAIInterpretPredictionsProvider.mjs.map +1 -0
  45. package/{lib-esm/providers/IdentifyTextUtils.js → dist/esm/providers/IdentifyTextUtils.mjs} +79 -142
  46. package/dist/esm/providers/IdentifyTextUtils.mjs.map +1 -0
  47. package/{lib-esm/providers/Utils.js → dist/esm/providers/Utils.mjs} +16 -14
  48. package/dist/esm/providers/Utils.mjs.map +1 -0
  49. package/dist/esm/providers/index.mjs +4 -0
  50. package/dist/esm/providers/index.mjs.map +1 -0
  51. package/dist/esm/types/AWSTypes.mjs +2 -0
  52. package/dist/esm/types/AWSTypes.mjs.map +1 -0
  53. package/{lib-esm → dist/esm}/types/Predictions.d.ts +14 -1
  54. package/dist/esm/types/Predictions.mjs +75 -0
  55. package/dist/esm/types/Predictions.mjs.map +1 -0
  56. package/dist/esm/types/index.mjs +2 -0
  57. package/dist/esm/types/index.mjs.map +1 -0
  58. package/package.json +26 -28
  59. package/src/types/Predictions.ts +16 -1
  60. package/lib/Predictions.d.ts +0 -15
  61. package/lib/errors/PredictionsError.d.ts +0 -4
  62. package/lib/errors/PredictionsError.js +0 -19
  63. package/lib/errors/types/validation.d.ts +0 -14
  64. package/lib/errors/utils/assertValidationError.d.ts +0 -2
  65. package/lib/errors/utils/assertValidationError.js +0 -14
  66. package/lib/index.d.ts +0 -2
  67. package/lib/providers/AmazonAIConvertPredictionsProvider.d.ts +0 -19
  68. package/lib/providers/AmazonAIConvertPredictionsProvider.js +0 -361
  69. package/lib/providers/AmazonAIIdentifyPredictionsProvider.d.ts +0 -48
  70. package/lib/providers/AmazonAIIdentifyPredictionsProvider.js +0 -398
  71. package/lib/providers/AmazonAIInterpretPredictionsProvider.d.ts +0 -14
  72. package/lib/providers/AmazonAIInterpretPredictionsProvider.js +0 -280
  73. package/lib/providers/IdentifyTextUtils.d.ts +0 -16
  74. package/lib/providers/Utils.d.ts +0 -13
  75. package/lib/providers/index.d.ts +0 -4
  76. package/lib/tsconfig.tsbuildinfo +0 -1
  77. package/lib/types/AWSTypes.d.ts +0 -124
  78. package/lib/types/Predictions.d.ts +0 -285
  79. package/lib/types/index.d.ts +0 -1
  80. package/lib-esm/Predictions.js +0 -27
  81. package/lib-esm/errors/PredictionsError.js +0 -16
  82. package/lib-esm/errors/utils/assertValidationError.js +0 -10
  83. package/lib-esm/index.js +0 -3
  84. package/lib-esm/providers/AmazonAIConvertPredictionsProvider.js +0 -358
  85. package/lib-esm/providers/AmazonAIIdentifyPredictionsProvider.js +0 -395
  86. package/lib-esm/providers/AmazonAIInterpretPredictionsProvider.js +0 -277
  87. package/lib-esm/providers/index.js +0 -6
  88. package/lib-esm/tsconfig.tsbuildinfo +0 -1
  89. package/lib-esm/types/AWSTypes.js +0 -1
  90. package/lib-esm/types/Predictions.js +0 -72
  91. package/lib-esm/types/index.js +0 -3
  92. /package/{lib-esm → dist/esm}/Predictions.d.ts +0 -0
  93. /package/{lib-esm → dist/esm}/errors/PredictionsError.d.ts +0 -0
  94. /package/{lib-esm → dist/esm}/errors/types/validation.d.ts +0 -0
  95. /package/{lib-esm → dist/esm}/errors/utils/assertValidationError.d.ts +0 -0
  96. /package/{lib-esm → dist/esm}/index.d.ts +0 -0
  97. /package/{lib-esm → dist/esm}/providers/AmazonAIConvertPredictionsProvider.d.ts +0 -0
  98. /package/{lib-esm → dist/esm}/providers/AmazonAIIdentifyPredictionsProvider.d.ts +0 -0
  99. /package/{lib-esm → dist/esm}/providers/AmazonAIInterpretPredictionsProvider.d.ts +0 -0
  100. /package/{lib-esm → dist/esm}/providers/IdentifyTextUtils.d.ts +0 -0
  101. /package/{lib-esm → dist/esm}/providers/Utils.d.ts +0 -0
  102. /package/{lib-esm → dist/esm}/providers/index.d.ts +0 -0
  103. /package/{lib-esm → dist/esm}/types/AWSTypes.d.ts +0 -0
  104. /package/{lib-esm → dist/esm}/types/index.d.ts +0 -0
@@ -1,30 +1,31 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.Predictions = exports.PredictionsClass = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
6
  // SPDX-License-Identifier: Apache-2.0
6
- var core_1 = require("@aws-amplify/core");
7
- var providers_1 = require("./providers");
8
- var logger = new core_1.ConsoleLogger('Predictions');
9
- var PredictionsClass = /** @class */ (function () {
10
- function PredictionsClass() {
7
+ const core_1 = require("@aws-amplify/core");
8
+ const providers_1 = require("./providers");
9
+ new core_1.ConsoleLogger('Predictions');
10
+ class PredictionsClass {
11
+ constructor() {
11
12
  this.convertProvider = new providers_1.AmazonAIConvertPredictionsProvider();
12
13
  this.identifyProvider = new providers_1.AmazonAIIdentifyPredictionsProvider();
13
14
  this.interpretProvider = new providers_1.AmazonAIInterpretPredictionsProvider();
14
15
  }
15
- PredictionsClass.prototype.getModuleName = function () {
16
+ getModuleName() {
16
17
  return 'Predictions';
17
- };
18
- PredictionsClass.prototype.interpret = function (input) {
18
+ }
19
+ interpret(input) {
19
20
  return this.interpretProvider.interpret(input);
20
- };
21
- PredictionsClass.prototype.convert = function (input) {
21
+ }
22
+ convert(input) {
22
23
  return this.convertProvider.convert(input);
23
- };
24
- PredictionsClass.prototype.identify = function (input) {
24
+ }
25
+ identify(input) {
25
26
  return this.identifyProvider.identify(input);
26
- };
27
- return PredictionsClass;
28
- }());
27
+ }
28
+ }
29
29
  exports.PredictionsClass = PredictionsClass;
30
30
  exports.Predictions = new PredictionsClass();
31
+ //# sourceMappingURL=Predictions.js.map
@@ -0,0 +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;;"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PredictionsError = void 0;
5
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ const utils_1 = require("@aws-amplify/core/internals/utils");
8
+ class PredictionsError extends utils_1.AmplifyError {
9
+ constructor(params) {
10
+ super(params);
11
+ // TODO: Delete the following 2 lines after we change the build target to >= es2015
12
+ this.constructor = PredictionsError;
13
+ Object.setPrototypeOf(this, PredictionsError.prototype);
14
+ }
15
+ }
16
+ exports.PredictionsError = PredictionsError;
17
+ //# sourceMappingURL=PredictionsError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PredictionsError.js","sources":["../../../src/errors/PredictionsError.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PredictionsError = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nclass PredictionsError extends utils_1.AmplifyError {\n constructor(params) {\n super(params);\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = PredictionsError;\n Object.setPrototypeOf(this, PredictionsError.prototype);\n }\n}\nexports.PredictionsError = PredictionsError;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAClC;AACA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,gBAAgB,SAAS,OAAO,CAAC,YAAY,CAAC;AACpD,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC,CAAC;AACtB;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC;AAC5C,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAChE,KAAK;AACL,CAAC;AACD,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;;"}
@@ -1,7 +1,7 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
- var _a;
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.validationErrorMap = exports.PredictionsValidationErrorCode = void 0;
7
7
  var PredictionsValidationErrorCode;
@@ -17,35 +17,36 @@ var PredictionsValidationErrorCode;
17
17
  PredictionsValidationErrorCode["NoTargetLanguage"] = "NoTargetLanguage";
18
18
  PredictionsValidationErrorCode["NoVoiceId"] = "NoVoiceId";
19
19
  })(PredictionsValidationErrorCode = exports.PredictionsValidationErrorCode || (exports.PredictionsValidationErrorCode = {}));
20
- exports.validationErrorMap = (_a = {},
21
- _a[PredictionsValidationErrorCode.CelebrityDetectionNotEnabled] = {
20
+ exports.validationErrorMap = {
21
+ [PredictionsValidationErrorCode.CelebrityDetectionNotEnabled]: {
22
22
  message: 'Celebrity Detection must be enabled.',
23
23
  },
24
- _a[PredictionsValidationErrorCode.InvalidInput] = {
24
+ [PredictionsValidationErrorCode.InvalidInput]: {
25
25
  message: 'Input does not conform to expected type.',
26
26
  },
27
- _a[PredictionsValidationErrorCode.InvalidSource] = {
27
+ [PredictionsValidationErrorCode.InvalidSource]: {
28
28
  message: 'Source type not supported.',
29
29
  },
30
- _a[PredictionsValidationErrorCode.NoCredentials] = {
30
+ [PredictionsValidationErrorCode.NoCredentials]: {
31
31
  message: 'Credentials should not be empty.',
32
32
  },
33
- _a[PredictionsValidationErrorCode.NoLanguage] = {
33
+ [PredictionsValidationErrorCode.NoLanguage]: {
34
34
  message: 'Missing language.',
35
35
  },
36
- _a[PredictionsValidationErrorCode.NoRegion] = {
36
+ [PredictionsValidationErrorCode.NoRegion]: {
37
37
  message: 'Missing region.',
38
38
  },
39
- _a[PredictionsValidationErrorCode.NoSource] = {
39
+ [PredictionsValidationErrorCode.NoSource]: {
40
40
  message: 'Missing source.',
41
41
  },
42
- _a[PredictionsValidationErrorCode.NoSourceLanguage] = {
42
+ [PredictionsValidationErrorCode.NoSourceLanguage]: {
43
43
  message: 'Missing source language for translation.',
44
44
  },
45
- _a[PredictionsValidationErrorCode.NoTargetLanguage] = {
45
+ [PredictionsValidationErrorCode.NoTargetLanguage]: {
46
46
  message: 'Missing target language for translation.',
47
47
  },
48
- _a[PredictionsValidationErrorCode.NoVoiceId] = {
48
+ [PredictionsValidationErrorCode.NoVoiceId]: {
49
49
  message: 'Missing voice id.',
50
50
  },
51
- _a);
51
+ };
52
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sources":["../../../../src/errors/types/validation.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.validationErrorMap = exports.PredictionsValidationErrorCode = void 0;\nvar PredictionsValidationErrorCode;\n(function (PredictionsValidationErrorCode) {\n PredictionsValidationErrorCode[\"CelebrityDetectionNotEnabled\"] = \"CelebrityDetectionNotEnabled\";\n PredictionsValidationErrorCode[\"InvalidInput\"] = \"InvalidInput\";\n PredictionsValidationErrorCode[\"InvalidSource\"] = \"InvalidSource\";\n PredictionsValidationErrorCode[\"NoCredentials\"] = \"NoCredentials\";\n PredictionsValidationErrorCode[\"NoLanguage\"] = \"NoLanguage\";\n PredictionsValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n PredictionsValidationErrorCode[\"NoSource\"] = \"NoSource\";\n PredictionsValidationErrorCode[\"NoSourceLanguage\"] = \"NoSourceLanguage\";\n PredictionsValidationErrorCode[\"NoTargetLanguage\"] = \"NoTargetLanguage\";\n PredictionsValidationErrorCode[\"NoVoiceId\"] = \"NoVoiceId\";\n})(PredictionsValidationErrorCode = exports.PredictionsValidationErrorCode || (exports.PredictionsValidationErrorCode = {}));\nexports.validationErrorMap = {\n [PredictionsValidationErrorCode.CelebrityDetectionNotEnabled]: {\n message: 'Celebrity Detection must be enabled.',\n },\n [PredictionsValidationErrorCode.InvalidInput]: {\n message: 'Input does not conform to expected type.',\n },\n [PredictionsValidationErrorCode.InvalidSource]: {\n message: 'Source type not supported.',\n },\n [PredictionsValidationErrorCode.NoCredentials]: {\n message: 'Credentials should not be empty.',\n },\n [PredictionsValidationErrorCode.NoLanguage]: {\n message: 'Missing language.',\n },\n [PredictionsValidationErrorCode.NoRegion]: {\n message: 'Missing region.',\n },\n [PredictionsValidationErrorCode.NoSource]: {\n message: 'Missing source.',\n },\n [PredictionsValidationErrorCode.NoSourceLanguage]: {\n message: 'Missing source language for translation.',\n },\n [PredictionsValidationErrorCode.NoTargetLanguage]: {\n message: 'Missing target language for translation.',\n },\n [PredictionsValidationErrorCode.NoVoiceId]: {\n message: 'Missing voice id.',\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC,CAAC;AAC7E,IAAI,8BAA8B,CAAC;AACnC,CAAC,UAAU,8BAA8B,EAAE;AAC3C,IAAI,8BAA8B,CAAC,8BAA8B,CAAC,GAAG,8BAA8B,CAAC;AACpG,IAAI,8BAA8B,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACpE,IAAI,8BAA8B,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACtE,IAAI,8BAA8B,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACtE,IAAI,8BAA8B,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAChE,IAAI,8BAA8B,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC5D,IAAI,8BAA8B,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC5D,IAAI,8BAA8B,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC5E,IAAI,8BAA8B,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC5E,IAAI,8BAA8B,CAAC,WAAW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", { value: true });
6
+ exports.assertValidationError = void 0;
7
+ const PredictionsError_1 = require("../PredictionsError");
8
+ const validation_1 = require("../types/validation");
9
+ function assertValidationError(assertion, name) {
10
+ if (!assertion) {
11
+ const { message, recoverySuggestion } = validation_1.validationErrorMap[name];
12
+ throw new PredictionsError_1.PredictionsError({ name, message, recoverySuggestion });
13
+ }
14
+ }
15
+ exports.assertValidationError = assertValidationError;
16
+ //# sourceMappingURL=assertValidationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertValidationError.js","sources":["../../../../src/errors/utils/assertValidationError.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.assertValidationError = void 0;\nconst PredictionsError_1 = require(\"../PredictionsError\");\nconst validation_1 = require(\"../types/validation\");\nfunction assertValidationError(assertion, name) {\n if (!assertion) {\n const { message, recoverySuggestion } = validation_1.validationErrorMap[name];\n throw new PredictionsError_1.PredictionsError({ name, message, recoverySuggestion });\n }\n}\nexports.assertValidationError = assertValidationError;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,KAAK,CAAC,CAAC;AACvC,MAAM,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACpD,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AAChD,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACtF,QAAQ,MAAM,IAAI,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC7F,KAAK;AACL,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
@@ -1,7 +1,9 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.Predictions = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
6
  // SPDX-License-Identifier: Apache-2.0
6
7
  var Predictions_1 = require("./Predictions");
7
8
  Object.defineProperty(exports, "Predictions", { enumerable: true, get: function () { return Predictions_1.Predictions; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Predictions = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar Predictions_1 = require(\"./Predictions\");\nObject.defineProperty(exports, \"Predictions\", { enumerable: true, get: function () { return Predictions_1.Predictions; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAC7B;AACA;AACA,IAAI,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC7C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC;;"}
@@ -0,0 +1,309 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AmazonAIConvertPredictionsProvider = void 0;
5
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ const core_1 = require("@aws-amplify/core");
8
+ const utils_1 = require("@aws-amplify/core/internals/utils");
9
+ const client_polly_1 = require("@aws-sdk/client-polly");
10
+ const client_translate_1 = require("@aws-sdk/client-translate");
11
+ const eventstream_codec_1 = require("@smithy/eventstream-codec");
12
+ const util_utf8_1 = require("@smithy/util-utf8");
13
+ const buffer_1 = require("buffer");
14
+ const validation_1 = require("../errors/types/validation");
15
+ const assertValidationError_1 = require("../errors/utils/assertValidationError");
16
+ const types_1 = require("../types");
17
+ const logger = new core_1.ConsoleLogger('AmazonAIConvertPredictionsProvider');
18
+ const eventBuilder = new eventstream_codec_1.EventStreamCodec(util_utf8_1.toUtf8, util_utf8_1.fromUtf8);
19
+ const LANGUAGES_CODE_IN_8KHZ = ['fr-FR', 'en-AU', 'en-GB', 'fr-CA'];
20
+ class AmazonAIConvertPredictionsProvider {
21
+ constructor() {
22
+ this.inputSampleRate = 44100;
23
+ }
24
+ getProviderName() {
25
+ return 'AmazonAIConvertPredictionsProvider';
26
+ }
27
+ convert(input) {
28
+ (0, assertValidationError_1.assertValidationError)((0, types_1.isValidConvertInput)(input), validation_1.PredictionsValidationErrorCode.InvalidInput);
29
+ if ((0, types_1.isTranslateTextInput)(input)) {
30
+ logger.debug('translateText');
31
+ return this.translateText(input);
32
+ }
33
+ else if ((0, types_1.isTextToSpeechInput)(input)) {
34
+ logger.debug('textToSpeech');
35
+ return this.convertTextToSpeech(input);
36
+ }
37
+ else {
38
+ logger.debug('textToSpeech');
39
+ return this.convertSpeechToText(input);
40
+ }
41
+ }
42
+ async translateText(input) {
43
+ logger.debug('Starting translation');
44
+ const { translateText = {} } = core_1.Amplify.getConfig().Predictions?.convert ?? {};
45
+ (0, assertValidationError_1.assertValidationError)(!!translateText.region, validation_1.PredictionsValidationErrorCode.NoRegion);
46
+ const { defaults = {}, region } = translateText;
47
+ const { credentials } = await (0, core_1.fetchAuthSession)();
48
+ (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);
49
+ const { sourceLanguage, targetLanguage } = defaults;
50
+ const sourceLanguageCode = input.translateText?.source?.language ?? sourceLanguage;
51
+ const targetLanguageCode = input.translateText?.targetLanguage ?? targetLanguage;
52
+ (0, assertValidationError_1.assertValidationError)(!!sourceLanguageCode, validation_1.PredictionsValidationErrorCode.NoSourceLanguage);
53
+ (0, assertValidationError_1.assertValidationError)(!!targetLanguageCode, validation_1.PredictionsValidationErrorCode.NoTargetLanguage);
54
+ this.translateClient = new client_translate_1.TranslateClient({
55
+ region,
56
+ credentials,
57
+ customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({
58
+ category: utils_1.Category.Predictions,
59
+ action: utils_1.PredictionsAction.Convert,
60
+ }),
61
+ });
62
+ const translateTextCommand = new client_translate_1.TranslateTextCommand({
63
+ SourceLanguageCode: sourceLanguageCode,
64
+ TargetLanguageCode: targetLanguageCode,
65
+ Text: input.translateText?.source?.text,
66
+ });
67
+ const data = await this.translateClient.send(translateTextCommand);
68
+ return {
69
+ text: data.TranslatedText,
70
+ language: data.TargetLanguageCode,
71
+ };
72
+ }
73
+ async convertTextToSpeech(input) {
74
+ const { credentials } = await (0, core_1.fetchAuthSession)();
75
+ (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);
76
+ (0, assertValidationError_1.assertValidationError)(!!input.textToSpeech?.source, validation_1.PredictionsValidationErrorCode.NoSource);
77
+ const { speechGenerator } = core_1.Amplify.getConfig().Predictions?.convert ?? {};
78
+ (0, assertValidationError_1.assertValidationError)(!!speechGenerator?.region, validation_1.PredictionsValidationErrorCode.NoRegion);
79
+ const { defaults = {}, region } = speechGenerator;
80
+ const { voiceId: defaultVoiceId } = defaults;
81
+ const voiceId = input.textToSpeech?.voiceId ?? defaultVoiceId;
82
+ (0, assertValidationError_1.assertValidationError)(!!voiceId, validation_1.PredictionsValidationErrorCode.NoVoiceId);
83
+ this.pollyClient = new client_polly_1.PollyClient({
84
+ region,
85
+ credentials,
86
+ customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({
87
+ category: utils_1.Category.Predictions,
88
+ action: utils_1.PredictionsAction.Convert,
89
+ }),
90
+ });
91
+ const synthesizeSpeechCommand = new client_polly_1.SynthesizeSpeechCommand({
92
+ OutputFormat: 'mp3',
93
+ Text: input.textToSpeech?.source?.text,
94
+ VoiceId: voiceId,
95
+ TextType: 'text',
96
+ SampleRate: '24000',
97
+ // tslint:disable-next-line: align
98
+ });
99
+ const data = await this.pollyClient.send(synthesizeSpeechCommand);
100
+ const response = new Response(data.AudioStream);
101
+ const arrayBuffer = await response.arrayBuffer();
102
+ const blob = new Blob([arrayBuffer], {
103
+ type: data.ContentType,
104
+ });
105
+ const url = URL.createObjectURL(blob);
106
+ return {
107
+ speech: { url },
108
+ audioStream: arrayBuffer,
109
+ text: input.textToSpeech?.source?.text,
110
+ };
111
+ }
112
+ async convertSpeechToText(input) {
113
+ logger.debug('starting transcription..');
114
+ const { credentials } = await (0, core_1.fetchAuthSession)();
115
+ (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);
116
+ const { transcription } = core_1.Amplify.getConfig().Predictions?.convert ?? {};
117
+ (0, assertValidationError_1.assertValidationError)(!!transcription?.region, validation_1.PredictionsValidationErrorCode.NoRegion);
118
+ const { defaults, region } = transcription;
119
+ const language = input.transcription?.language ?? defaults?.language;
120
+ (0, assertValidationError_1.assertValidationError)(!!language, validation_1.PredictionsValidationErrorCode.NoLanguage);
121
+ const source = input.transcription?.source;
122
+ (0, assertValidationError_1.assertValidationError)((0, types_1.isConvertBytesSource)(source), validation_1.PredictionsValidationErrorCode.InvalidSource);
123
+ const connection = await this.openConnectionWithTranscribe({
124
+ credentials,
125
+ region,
126
+ languageCode: language,
127
+ });
128
+ const fullText = await this.sendDataToTranscribe({
129
+ connection,
130
+ raw: source.bytes,
131
+ languageCode: language,
132
+ });
133
+ return {
134
+ transcription: {
135
+ fullText,
136
+ },
137
+ };
138
+ }
139
+ static serializeDataFromTranscribe(message) {
140
+ let decodedMessage = '';
141
+ const transcribeMessage = eventBuilder.decode(buffer_1.Buffer.from(message.data));
142
+ const transcribeMessageJson = JSON.parse((0, util_utf8_1.toUtf8)(transcribeMessage.body));
143
+ if (transcribeMessage.headers[':message-type'].value === 'exception') {
144
+ logger.debug('exception', JSON.stringify(transcribeMessageJson.Message, null, 2));
145
+ throw new Error(transcribeMessageJson.Message);
146
+ }
147
+ else if (transcribeMessage.headers[':message-type'].value === 'event') {
148
+ if (transcribeMessageJson.Transcript.Results.length > 0) {
149
+ if (transcribeMessageJson.Transcript.Results[0].Alternatives.length > 0) {
150
+ if (transcribeMessageJson.Transcript.Results[0].Alternatives[0]
151
+ .Transcript.length > 0) {
152
+ if (transcribeMessageJson.Transcript.Results[0].IsPartial === false) {
153
+ decodedMessage =
154
+ transcribeMessageJson.Transcript.Results[0].Alternatives[0]
155
+ .Transcript + '\n';
156
+ logger.debug({ decodedMessage });
157
+ }
158
+ else {
159
+ logger.debug({
160
+ transcript: transcribeMessageJson.Transcript.Results[0].Alternatives[0],
161
+ });
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
167
+ return decodedMessage;
168
+ }
169
+ sendDataToTranscribe({ connection, raw, languageCode, }) {
170
+ return new Promise((res, rej) => {
171
+ let fullText = '';
172
+ connection.onmessage = message => {
173
+ try {
174
+ const decodedMessage = AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe(message);
175
+ if (decodedMessage) {
176
+ fullText += decodedMessage + ' ';
177
+ }
178
+ }
179
+ catch (err) {
180
+ logger.debug(err);
181
+ rej(err);
182
+ }
183
+ };
184
+ connection.onerror = errorEvent => {
185
+ logger.debug({ errorEvent });
186
+ rej('failed to transcribe, network error');
187
+ };
188
+ connection.onclose = closeEvent => {
189
+ logger.debug({ closeEvent });
190
+ return res(fullText.trim());
191
+ };
192
+ logger.debug({ raw });
193
+ if (Array.isArray(raw)) {
194
+ for (let i = 0; i < raw.length - 1023; i += 1024) {
195
+ const data = raw.slice(i, i + 1024);
196
+ this.sendEncodedDataToTranscribe(connection, data, languageCode);
197
+ }
198
+ }
199
+ else {
200
+ // If Buffer
201
+ this.sendEncodedDataToTranscribe(connection, raw, languageCode);
202
+ }
203
+ // sending end frame
204
+ const endFrameEventMessage = this.getAudioEventMessage(buffer_1.Buffer.from([]));
205
+ const endFrameBinary = eventBuilder.encode(endFrameEventMessage);
206
+ connection.send(endFrameBinary);
207
+ });
208
+ }
209
+ sendEncodedDataToTranscribe(connection, data, languageCode) {
210
+ const downsampledBuffer = this.downsampleBuffer({
211
+ buffer: data,
212
+ outputSampleRate: LANGUAGES_CODE_IN_8KHZ.includes(languageCode)
213
+ ? 8000
214
+ : 16000,
215
+ });
216
+ const pcmEncodedBuffer = this.pcmEncode(downsampledBuffer);
217
+ const audioEventMessage = this.getAudioEventMessage(buffer_1.Buffer.from(pcmEncodedBuffer));
218
+ const binary = eventBuilder.encode(audioEventMessage);
219
+ connection.send(binary);
220
+ }
221
+ getAudioEventMessage(buffer) {
222
+ const audioEventMessage = {
223
+ body: buffer,
224
+ headers: {
225
+ ':message-type': {
226
+ type: 'string',
227
+ value: 'event',
228
+ },
229
+ ':event-type': {
230
+ type: 'string',
231
+ value: 'AudioEvent',
232
+ },
233
+ },
234
+ };
235
+ return audioEventMessage;
236
+ }
237
+ pcmEncode(input) {
238
+ let offset = 0;
239
+ // ArrayBuffer cannot be processed using length property
240
+ if (input instanceof ArrayBuffer) {
241
+ return input;
242
+ }
243
+ const buffer = new ArrayBuffer(input.length * 2);
244
+ const view = new DataView(buffer);
245
+ for (let i = 0; i < input.length; i++, offset += 2) {
246
+ const s = Math.max(-1, Math.min(1, input[i]));
247
+ view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
248
+ }
249
+ return buffer;
250
+ }
251
+ downsampleBuffer({ buffer, outputSampleRate = 16000, }) {
252
+ // Cannot process ArrayBuffer using length property
253
+ if (outputSampleRate === this.inputSampleRate ||
254
+ buffer instanceof ArrayBuffer) {
255
+ return buffer;
256
+ }
257
+ const sampleRateRatio = this.inputSampleRate / outputSampleRate;
258
+ const newLength = Math.round(buffer.length / sampleRateRatio);
259
+ const result = new Float32Array(newLength);
260
+ let offsetResult = 0;
261
+ let offsetBuffer = 0;
262
+ while (offsetResult < result.length) {
263
+ const nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);
264
+ let accum = 0, count = 0;
265
+ for (let i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {
266
+ accum += buffer[i];
267
+ count++;
268
+ }
269
+ result[offsetResult] = accum / count;
270
+ offsetResult++;
271
+ offsetBuffer = nextOffsetBuffer;
272
+ }
273
+ return result;
274
+ }
275
+ openConnectionWithTranscribe({ credentials, region, languageCode, }) {
276
+ return new Promise(async (res, rej) => {
277
+ const signedUrl = this.generateTranscribeUrl({
278
+ credentials,
279
+ region,
280
+ languageCode,
281
+ });
282
+ logger.debug('connecting...');
283
+ const connection = new WebSocket(signedUrl);
284
+ connection.binaryType = 'arraybuffer';
285
+ connection.onopen = () => {
286
+ logger.debug('connected');
287
+ res(connection);
288
+ };
289
+ });
290
+ }
291
+ generateTranscribeUrl({ credentials: { accessKeyId, secretAccessKey, sessionToken }, region, languageCode, }) {
292
+ const credentials = {
293
+ access_key: accessKeyId,
294
+ secret_key: secretAccessKey,
295
+ session_token: sessionToken,
296
+ };
297
+ const url = [
298
+ `wss://transcribestreaming.${region}.amazonaws.com:8443`,
299
+ '/stream-transcription-websocket?',
300
+ `media-encoding=pcm&`,
301
+ `sample-rate=${LANGUAGES_CODE_IN_8KHZ.includes(languageCode) ? '8000' : '16000'}&`,
302
+ `language-code=${languageCode}`,
303
+ ].join('');
304
+ const signedUrl = utils_1.Signer.signUrl(url, credentials, { region, service: 'transcribe' }, 300);
305
+ return signedUrl;
306
+ }
307
+ }
308
+ exports.AmazonAIConvertPredictionsProvider = AmazonAIConvertPredictionsProvider;
309
+ //# sourceMappingURL=AmazonAIConvertPredictionsProvider.js.map
@@ -0,0 +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;AACjF,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,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