@dataclouder/conversation-card-nestjs 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. package/dist/{libs/conversation-cards/src/ai-models.service.d.ts → ai-models.service.d.ts} +1 -0
  2. package/dist/ai-models.service.d.ts.map +1 -0
  3. package/dist/ai-models.service.js +71 -173
  4. package/dist/ai-models.service.js.map +1 -0
  5. package/dist/{libs/conversation-cards/src/clases → clases}/conversation.interface.d.ts +1 -0
  6. package/dist/clases/conversation.interface.d.ts.map +1 -0
  7. package/dist/clases/conversation.interface.js +9 -20
  8. package/dist/clases/conversation.interface.js.map +1 -0
  9. package/dist/{libs/conversation-cards/src/conversation-ai.controller.d.ts → conversation-ai.controller.d.ts} +2 -6
  10. package/dist/conversation-ai.controller.d.ts.map +1 -0
  11. package/dist/conversation-ai.controller.js +117 -209
  12. package/dist/conversation-ai.controller.js.map +1 -0
  13. package/dist/conversation-cards.module.d.ts +3 -0
  14. package/dist/conversation-cards.module.d.ts.map +1 -0
  15. package/dist/conversation-cards.module.js +22 -69
  16. package/dist/conversation-cards.module.js.map +1 -0
  17. package/dist/{libs/conversation-cards/src/conversation.controller.d.ts → conversation.controller.d.ts} +1 -0
  18. package/dist/conversation.controller.d.ts.map +1 -0
  19. package/dist/conversation.controller.js +27 -106
  20. package/dist/conversation.controller.js.map +1 -0
  21. package/dist/{libs/conversation-cards/src/dto → dto}/create-conversation.dto.d.ts +1 -0
  22. package/dist/dto/create-conversation.dto.d.ts.map +1 -0
  23. package/dist/dto/create-conversation.dto.js +35 -78
  24. package/dist/dto/create-conversation.dto.js.map +1 -0
  25. package/dist/{libs/conversation-cards/src/entities → entities}/conversation.entity.d.ts +1 -0
  26. package/dist/entities/conversation.entity.d.ts.map +1 -0
  27. package/dist/entities/conversation.entity.js +84 -145
  28. package/dist/entities/conversation.entity.js.map +1 -0
  29. package/dist/{libs/conversation-cards/src/index.d.ts → index.d.ts} +1 -1
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +1 -1
  32. package/dist/index.js.map +1 -0
  33. package/dist/services/audio-transcription.service.d.ts +1 -0
  34. package/dist/services/audio-transcription.service.d.ts.map +1 -0
  35. package/dist/services/audio-transcription.service.js +1 -27
  36. package/dist/services/audio-transcription.service.js.map +1 -0
  37. package/dist/{libs/conversation-cards/src/services → services}/conversation-ai.service.d.ts +1 -0
  38. package/dist/services/conversation-ai.service.d.ts.map +1 -0
  39. package/dist/services/conversation-ai.service.js +50 -143
  40. package/dist/services/conversation-ai.service.js.map +1 -0
  41. package/dist/services/conversation-cards.service.d.ts +3 -0
  42. package/dist/services/conversation-cards.service.d.ts.map +1 -0
  43. package/dist/services/conversation-cards.service.js +12 -58
  44. package/dist/services/conversation-cards.service.js.map +1 -0
  45. package/dist/tts/tts-service.d.ts +1 -0
  46. package/dist/tts/tts-service.d.ts.map +1 -0
  47. package/dist/tts/tts-service.js +1 -250
  48. package/dist/tts/tts-service.js.map +1 -0
  49. package/dist/{libs/conversation-cards/src/tts → tts}/tts.classes.d.ts +1 -0
  50. package/dist/tts/tts.classes.d.ts.map +1 -0
  51. package/dist/tts/tts.classes.js +3 -13
  52. package/dist/tts/tts.classes.js.map +1 -0
  53. package/dist/{libs/conversation-cards/src/tts → tts}/voices.d.ts +1 -0
  54. package/dist/tts/voices.d.ts.map +1 -0
  55. package/dist/tts/voices.js +1 -10
  56. package/dist/tts/voices.js.map +1 -0
  57. package/package.json +1 -1
  58. package/dist/conversation-ai.module.js +0 -74
  59. package/dist/libs/conversation-cards/src/ai-models.service.js +0 -82
  60. package/dist/libs/conversation-cards/src/ai-models.service.js.map +0 -1
  61. package/dist/libs/conversation-cards/src/clases/conversation.interface.js +0 -40
  62. package/dist/libs/conversation-cards/src/clases/conversation.interface.js.map +0 -1
  63. package/dist/libs/conversation-cards/src/conversation-ai.controller.js +0 -153
  64. package/dist/libs/conversation-cards/src/conversation-ai.controller.js.map +0 -1
  65. package/dist/libs/conversation-cards/src/conversation-ai.module.d.ts +0 -2
  66. package/dist/libs/conversation-cards/src/conversation-ai.module.js +0 -28
  67. package/dist/libs/conversation-cards/src/conversation-ai.module.js.map +0 -1
  68. package/dist/libs/conversation-cards/src/conversation-cards.module.d.ts +0 -2
  69. package/dist/libs/conversation-cards/src/conversation-cards.module.js +0 -28
  70. package/dist/libs/conversation-cards/src/conversation-cards.module.js.map +0 -1
  71. package/dist/libs/conversation-cards/src/conversation.controller.js +0 -33
  72. package/dist/libs/conversation-cards/src/conversation.controller.js.map +0 -1
  73. package/dist/libs/conversation-cards/src/dto/create-conversation.dto.js +0 -42
  74. package/dist/libs/conversation-cards/src/dto/create-conversation.dto.js.map +0 -1
  75. package/dist/libs/conversation-cards/src/entities/conversation.entity.js +0 -97
  76. package/dist/libs/conversation-cards/src/entities/conversation.entity.js.map +0 -1
  77. package/dist/libs/conversation-cards/src/index.js +0 -24
  78. package/dist/libs/conversation-cards/src/index.js.map +0 -1
  79. package/dist/libs/conversation-cards/src/services/audio-transcription.service.d.ts +0 -0
  80. package/dist/libs/conversation-cards/src/services/audio-transcription.service.js +0 -1
  81. package/dist/libs/conversation-cards/src/services/audio-transcription.service.js.map +0 -1
  82. package/dist/libs/conversation-cards/src/services/conversation-ai.service.js +0 -58
  83. package/dist/libs/conversation-cards/src/services/conversation-ai.service.js.map +0 -1
  84. package/dist/libs/conversation-cards/src/services/conversation-cards.service.d.ts +0 -2
  85. package/dist/libs/conversation-cards/src/services/conversation-cards.service.js +0 -17
  86. package/dist/libs/conversation-cards/src/services/conversation-cards.service.js.map +0 -1
  87. package/dist/libs/conversation-cards/src/tts/tts-service.d.ts +0 -20
  88. package/dist/libs/conversation-cards/src/tts/tts-service.js +0 -124
  89. package/dist/libs/conversation-cards/src/tts/tts-service.js.map +0 -1
  90. package/dist/libs/conversation-cards/src/tts/tts.classes.js +0 -200
  91. package/dist/libs/conversation-cards/src/tts/tts.classes.js.map +0 -1
  92. package/dist/libs/conversation-cards/src/tts/voices.js +0 -208
  93. package/dist/libs/conversation-cards/src/tts/voices.js.map +0 -1
  94. package/dist/src/common/app-exception.d.ts +0 -28
  95. package/dist/src/common/app-exception.js +0 -28
  96. package/dist/src/common/app-exception.js.map +0 -1
  97. package/dist/tsconfig.lib.tsbuildinfo +0 -1
@@ -1,151 +1,58 @@
1
1
  "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
28
7
  };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
- function verb(n) { return function (v) { return step([n, v]); }; }
49
- function step(op) {
50
- if (f) throw new TypeError("Generator is already executing.");
51
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
- if (y = 0, t) op = [op[0] & 2, t.value];
54
- switch (op[0]) {
55
- case 0: case 1: t = op; break;
56
- case 4: _.label++; return { value: op[1], done: false };
57
- case 5: _.label++; y = op[1]; op = [0]; continue;
58
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
- default:
60
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
- if (t[2]) _.ops.pop();
65
- _.trys.pop(); continue;
66
- }
67
- op = body.call(thisArg, _);
68
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
- }
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
71
10
  };
72
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
73
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
74
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
75
13
  };
76
14
  Object.defineProperty(exports, "__esModule", { value: true });
77
15
  exports.ConversationAiService = void 0;
78
- var common_1 = require("@nestjs/common");
79
- var groq_sdk_1 = require("groq-sdk");
80
- var mongodb_1 = require("mongodb");
81
- var ConversationAiService = function () {
82
- var _classDecorators = [(0, common_1.Injectable)()];
83
- var _classDescriptor;
84
- var _classExtraInitializers = [];
85
- var _classThis;
86
- var ConversationAiService = _classThis = /** @class */ (function () {
87
- function ConversationAiService_1(conversationModel) {
88
- this.conversationModel = conversationModel;
89
- this.groqClient = new groq_sdk_1.default({
90
- apiKey: process.env['GROQ_API_KEY'],
91
- });
16
+ const common_1 = require("@nestjs/common");
17
+ const mongoose_1 = require("@nestjs/mongoose");
18
+ const mongoose_2 = require("mongoose");
19
+ const groq_sdk_1 = require("groq-sdk");
20
+ const mongodb_1 = require("mongodb");
21
+ const conversation_entity_1 = require("../entities/conversation.entity");
22
+ let ConversationAiService = class ConversationAiService {
23
+ constructor(conversationModel) {
24
+ this.conversationModel = conversationModel;
25
+ this.groqClient = new groq_sdk_1.default({
26
+ apiKey: process.env['GROQ_API_KEY'],
27
+ });
28
+ }
29
+ async saveConversation(conversation) {
30
+ if (!conversation['_id']) {
31
+ delete conversation['_id'];
92
32
  }
93
- ConversationAiService_1.prototype.saveConversation = function (conversation) {
94
- return __awaiter(this, void 0, void 0, function () {
95
- var newConversation;
96
- return __generator(this, function (_a) {
97
- if (!conversation['_id']) {
98
- delete conversation['_id'];
99
- }
100
- newConversation = new this.conversationModel(conversation);
101
- return [2 /*return*/, newConversation.save()];
102
- });
103
- });
104
- };
105
- ConversationAiService_1.prototype.updateConversation = function (id, updateData) {
106
- return __awaiter(this, void 0, void 0, function () {
107
- var _id;
108
- return __generator(this, function (_a) {
109
- _id = new mongodb_1.ObjectId(id);
110
- return [2 /*return*/, this.conversationModel.findByIdAndUpdate(_id, updateData, { new: true }).exec()];
111
- });
112
- });
113
- };
114
- ConversationAiService_1.prototype.getConversations = function () {
115
- return __awaiter(this, void 0, void 0, function () {
116
- return __generator(this, function (_a) {
117
- return [2 /*return*/, this.conversationModel.find().exec()];
118
- });
119
- });
120
- };
121
- ConversationAiService_1.prototype.getConversationById = function (id) {
122
- return __awaiter(this, void 0, void 0, function () {
123
- var _id;
124
- return __generator(this, function (_a) {
125
- _id = new mongodb_1.ObjectId(id);
126
- return [2 /*return*/, this.conversationModel.findById(_id).exec()];
127
- });
128
- });
129
- };
130
- ConversationAiService_1.prototype.deleteConversationById = function (id) {
131
- return __awaiter(this, void 0, void 0, function () {
132
- var _id;
133
- return __generator(this, function (_a) {
134
- _id = new mongodb_1.ObjectId(id);
135
- return [2 /*return*/, this.conversationModel.findByIdAndDelete(_id).exec()];
136
- });
137
- });
138
- };
139
- return ConversationAiService_1;
140
- }());
141
- __setFunctionName(_classThis, "ConversationAiService");
142
- (function () {
143
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
144
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
145
- ConversationAiService = _classThis = _classDescriptor.value;
146
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
147
- __runInitializers(_classThis, _classExtraInitializers);
148
- })();
149
- return ConversationAiService = _classThis;
150
- }();
33
+ const newConversation = new this.conversationModel(conversation);
34
+ return newConversation.save();
35
+ }
36
+ async updateConversation(id, updateData) {
37
+ const _id = new mongodb_1.ObjectId(id);
38
+ return this.conversationModel.findByIdAndUpdate(_id, updateData, { new: true }).exec();
39
+ }
40
+ async getConversations() {
41
+ return this.conversationModel.find().exec();
42
+ }
43
+ async getConversationById(id) {
44
+ const _id = new mongodb_1.ObjectId(id);
45
+ return this.conversationModel.findById(_id).exec();
46
+ }
47
+ async deleteConversationById(id) {
48
+ const _id = new mongodb_1.ObjectId(id);
49
+ return this.conversationModel.findByIdAndDelete(_id).exec();
50
+ }
51
+ };
151
52
  exports.ConversationAiService = ConversationAiService;
53
+ exports.ConversationAiService = ConversationAiService = __decorate([
54
+ (0, common_1.Injectable)(),
55
+ __param(0, (0, mongoose_1.InjectModel)(conversation_entity_1.Conversation.name)),
56
+ __metadata("design:paramtypes", [mongoose_2.Model])
57
+ ], ConversationAiService);
58
+ //# sourceMappingURL=conversation-ai.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-ai.service.js","sourceRoot":"","sources":["../../src/services/conversation-ai.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA+C;AAC/C,uCAAiC;AACjC,uCAA4B;AAE5B,qCAAmC;AAGnC,yEAAqF;AAG9E,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAGhC,YAAoD,iBAA8C;QAA9C,sBAAiB,GAAjB,iBAAiB,CAA6B;QAChG,IAAI,CAAC,UAAU,GAAG,IAAI,kBAAI,CAAC;YACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;SACpC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,YAA+B;QACpD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;SAC5B;QAED,MAAM,eAAe,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;QACjE,OAAO,eAAe,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,EAAU,EAAE,UAAiC;QACpE,MAAM,GAAG,GAAG,IAAI,kBAAQ,CAAC,EAAE,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,EAAU;QAClC,MAAM,GAAG,GAAG,IAAI,kBAAQ,CAAC,EAAE,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,EAAU;QACrC,MAAM,GAAG,GAAG,IAAI,kBAAQ,CAAC,EAAE,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9D,CAAC;CACF,CAAA;AApCY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAIE,WAAA,IAAA,sBAAW,EAAC,kCAAY,CAAC,IAAI,CAAC,CAAA;qCAA4B,gBAAK;GAHjE,qBAAqB,CAoCjC"}
@@ -0,0 +1,3 @@
1
+ export declare class ConversationCardsService {
2
+ }
3
+ //# sourceMappingURL=conversation-cards.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-cards.service.d.ts","sourceRoot":"","sources":["../../src/services/conversation-cards.service.ts"],"names":[],"mappings":"AAEA,qBACa,wBAAwB;CAAG"}
@@ -1,63 +1,17 @@
1
1
  "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
39
7
  };
40
8
  Object.defineProperty(exports, "__esModule", { value: true });
41
9
  exports.ConversationCardsService = void 0;
42
- var common_1 = require("@nestjs/common");
43
- var ConversationCardsService = function () {
44
- var _classDecorators = [(0, common_1.Injectable)()];
45
- var _classDescriptor;
46
- var _classExtraInitializers = [];
47
- var _classThis;
48
- var ConversationCardsService = _classThis = /** @class */ (function () {
49
- function ConversationCardsService_1() {
50
- }
51
- return ConversationCardsService_1;
52
- }());
53
- __setFunctionName(_classThis, "ConversationCardsService");
54
- (function () {
55
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
56
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
57
- ConversationCardsService = _classThis = _classDescriptor.value;
58
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
59
- __runInitializers(_classThis, _classExtraInitializers);
60
- })();
61
- return ConversationCardsService = _classThis;
62
- }();
10
+ const common_1 = require("@nestjs/common");
11
+ let ConversationCardsService = class ConversationCardsService {
12
+ };
63
13
  exports.ConversationCardsService = ConversationCardsService;
14
+ exports.ConversationCardsService = ConversationCardsService = __decorate([
15
+ (0, common_1.Injectable)()
16
+ ], ConversationCardsService);
17
+ //# sourceMappingURL=conversation-cards.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-cards.service.js","sourceRoot":"","sources":["../../src/services/conversation-cards.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAAG,CAAA;AAA3B,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;GACA,wBAAwB,CAAG"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=tts-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tts-service.d.ts","sourceRoot":"","sources":["../../src/tts/tts-service.ts"],"names":[],"mappings":""}
@@ -1,250 +1 @@
1
- "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
- function verb(n) { return function (v) { return step([n, v]); }; }
49
- function step(op) {
50
- if (f) throw new TypeError("Generator is already executing.");
51
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
- if (y = 0, t) op = [op[0] & 2, t.value];
54
- switch (op[0]) {
55
- case 0: case 1: t = op; break;
56
- case 4: _.label++; return { value: op[1], done: false };
57
- case 5: _.label++; y = op[1]; op = [0]; continue;
58
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
- default:
60
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
- if (t[2]) _.ops.pop();
65
- _.trys.pop(); continue;
66
- }
67
- op = body.call(thisArg, _);
68
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
- }
71
- };
72
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
73
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
74
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
75
- };
76
- Object.defineProperty(exports, "__esModule", { value: true });
77
- exports.TTSService = void 0;
78
- // src/services/text-to-speech.service.ts
79
- var textToSpeech = require("@google-cloud/text-to-speech");
80
- // import { creds } from '../resources/environment';
81
- // import { SynthAudioOptions } from '../core/app-models';
82
- // import { AudioSpeed, VoiceCode } from '../core/app-enums';
83
- var tts_classes_1 = require("./tts.classes");
84
- var app_exception_1 = require("src/common/app-exception");
85
- var common_1 = require("@nestjs/common");
86
- var TTSService = function () {
87
- var _classDecorators = [(0, common_1.Injectable)()];
88
- var _classDescriptor;
89
- var _classExtraInitializers = [];
90
- var _classThis;
91
- var TTSService = _classThis = /** @class */ (function () {
92
- function TTSService_1() {
93
- try {
94
- // Explicitly specify the credentials file path
95
- // const keyFilename = process.env.GOOGLE_APPLICATION_CREDENTIALS;
96
- // if (!keyFilename) {
97
- // throw new Error('GOOGLE_APPLICATION_CREDENTIALS environment variable is not set');
98
- // }
99
- console.log('Initializing Text-to-Speech client');
100
- this.client = new textToSpeech.TextToSpeechClient();
101
- }
102
- catch (error) {
103
- console.error('Error initializing Text-to-Speech client:', error);
104
- throw new app_exception_1.AppException({
105
- error_message: 'Failed to initialize Text-to-Speech client',
106
- explanation: 'Please ensure Google Cloud credentials are properly configured.',
107
- exception: error,
108
- });
109
- }
110
- }
111
- // Converts get_speech function
112
- TTSService_1.prototype.getSpeech = function (tts) {
113
- var _a;
114
- return __awaiter(this, void 0, void 0, function () {
115
- var selectedVoiceName, languageCode, voiceOptions, voiceData, voice, speakingRate, request, response;
116
- return __generator(this, function (_b) {
117
- switch (_b.label) {
118
- case 0:
119
- console.log('Voice name:', tts.voiceName, 'Options:', tts.options, 'Lang:', tts.lang, 'is_ssml:', tts.isSsml);
120
- if (!tts.voiceName) {
121
- voiceOptions = tts_classes_1.GoogleVoiceHQOptions.filter(function (voice) { return voice.lang.includes(tts.lang); });
122
- voiceData = voiceOptions[Math.floor(Math.random() * voiceOptions.length)];
123
- selectedVoiceName = voiceData.id;
124
- languageCode = voiceData.lang;
125
- }
126
- else {
127
- voice = tts_classes_1.GoogleVoiceOptions.find(function (item) { return item.id === tts.voiceName; });
128
- if (!voice) {
129
- throw new app_exception_1.AppException({ error_message: "Voice ".concat(tts.voiceName, " not found") });
130
- }
131
- selectedVoiceName = tts.voiceName;
132
- languageCode = voice.lang;
133
- }
134
- speakingRate = 1;
135
- if (tts.options && !selectedVoiceName.includes('Journey')) {
136
- speakingRate = tts.options.speed_rate && tts.options.speed_rate > 0 ? tts.options.speed_rate : this.getSpeedRate((_a = tts.options) === null || _a === void 0 ? void 0 : _a.speed);
137
- }
138
- request = {
139
- input: tts.isSsml ? { ssml: tts.text } : { text: tts.text },
140
- voice: {
141
- languageCode: languageCode,
142
- name: selectedVoiceName,
143
- },
144
- audioConfig: {
145
- audioEncoding: 'MP3',
146
- speakingRate: speakingRate,
147
- },
148
- };
149
- return [4 /*yield*/, this.client.synthesizeSpeech(request)];
150
- case 1:
151
- response = (_b.sent())[0];
152
- return [2 /*return*/, {
153
- audioContent: response.audioContent,
154
- voiceName: selectedVoiceName,
155
- }];
156
- }
157
- });
158
- });
159
- };
160
- // Converts get_speed_rate function
161
- TTSService_1.prototype.getSpeedRate = function (speed) {
162
- switch (speed) {
163
- case tts_classes_1.AudioSpeed.VeryFast:
164
- return 1.5;
165
- case tts_classes_1.AudioSpeed.Fast:
166
- return 1.25;
167
- case tts_classes_1.AudioSpeed.Regular:
168
- return 1.0;
169
- case tts_classes_1.AudioSpeed.Slow:
170
- return 0.75;
171
- case tts_classes_1.AudioSpeed.VerySlow:
172
- return 0.5;
173
- default:
174
- return 1.0;
175
- }
176
- };
177
- // Converts list_voices function
178
- TTSService_1.prototype.listVoices = function (languageCode) {
179
- var _a;
180
- if (languageCode === void 0) { languageCode = 'en-US'; }
181
- return __awaiter(this, void 0, void 0, function () {
182
- var response, voices;
183
- return __generator(this, function (_b) {
184
- switch (_b.label) {
185
- case 0: return [4 /*yield*/, this.client.listVoices({ languageCode: languageCode })];
186
- case 1:
187
- response = (_b.sent())[0];
188
- voices = ((_a = response.voices) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.name.localeCompare(b.name); })) || [];
189
- console.log(" Voices: ".concat(voices.length, " ").padStart(60, '-').padEnd(60, '-'));
190
- voices.forEach(function (voice) {
191
- var _a;
192
- var languages = ((_a = voice.languageCodes) === null || _a === void 0 ? void 0 : _a.join(', ')) || '';
193
- var name = voice.name;
194
- var gender = voice.ssmlGender;
195
- var rate = voice.naturalSampleRateHertz;
196
- console.log("".concat(languages, " | ").concat(name, " | ").concat(gender, " | ").concat(rate === null || rate === void 0 ? void 0 : rate.toLocaleString(), " Hz"));
197
- });
198
- return [2 /*return*/];
199
- }
200
- });
201
- });
202
- };
203
- // Converts text_to_wav function
204
- TTSService_1.prototype.textToWav = function (voiceName, text) {
205
- return __awaiter(this, void 0, void 0, function () {
206
- var languageCode, request, response, filename;
207
- return __generator(this, function (_a) {
208
- switch (_a.label) {
209
- case 0:
210
- languageCode = voiceName.split('-').slice(0, 2).join('-');
211
- request = {
212
- input: { text: text },
213
- voice: {
214
- languageCode: languageCode,
215
- name: voiceName,
216
- },
217
- audioConfig: {
218
- audioEncoding: 'LINEAR16',
219
- pitch: -1.0,
220
- speakingRate: 0.9,
221
- },
222
- };
223
- return [4 /*yield*/, this.client.synthesizeSpeech(request)];
224
- case 1:
225
- response = (_a.sent())[0];
226
- console.log(response);
227
- filename = "".concat(languageCode, ".wav");
228
- // Note: In a real TypeScript/Node.js application, you'd use fs to write the file
229
- // For this example, I'll leave a placeholder comment
230
- // import * as fs from 'fs';
231
- // fs.writeFileSync(filename, response.audioContent);
232
- console.log("Generated speech saved to \"".concat(filename, "\""));
233
- return [2 /*return*/];
234
- }
235
- });
236
- });
237
- };
238
- return TTSService_1;
239
- }());
240
- __setFunctionName(_classThis, "TTSService");
241
- (function () {
242
- var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
243
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
244
- TTSService = _classThis = _classDescriptor.value;
245
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
246
- __runInitializers(_classThis, _classExtraInitializers);
247
- })();
248
- return TTSService = _classThis;
249
- }();
250
- exports.TTSService = TTSService;
1
+ //# sourceMappingURL=tts-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tts-service.js","sourceRoot":"","sources":["../../src/tts/tts-service.ts"],"names":[],"mappings":""}
@@ -30,3 +30,4 @@ export declare class TTSDto {
30
30
  speedRate: number;
31
31
  generateTranscription: boolean;
32
32
  }
33
+ //# sourceMappingURL=tts.classes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tts.classes.d.ts","sourceRoot":"","sources":["../../src/tts/tts.classes.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,oBAAY,SAAS;IACnB,EAAE,OAAO;CACV;AAMD,eAAO,MAAM,oBAAoB,EAAE,WAAW,EAI7C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,WAAW,EAyL3C,CAAC;AAIF,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB,EAAE,OAAO,CAAC;CAChC"}
@@ -13,12 +13,8 @@ var VoiceCode;
13
13
  (function (VoiceCode) {
14
14
  VoiceCode["MX"] = "MX";
15
15
  })(VoiceCode || (exports.VoiceCode = VoiceCode = {}));
16
- // export enum VoiceType {
17
- // }
18
16
  exports.GoogleVoiceHQOptions = [
19
- // Populate with your high-quality voice options
20
17
  { id: 'en-US-Neural2-A', lang: 'en-US' },
21
- // Add more voices as needed
22
18
  ];
23
19
  exports.GoogleVoiceOptions = [
24
20
  {
@@ -37,7 +33,6 @@ exports.GoogleVoiceOptions = [
37
33
  lang: 'fr-FR',
38
34
  exampleUrl: 'https://storage.googleapis.com/appingles-pro.appspot.com/voice_demos/google_fr-FR-Neural2-E.mp3',
39
35
  },
40
- // Italian
41
36
  {
42
37
  provider: 'google',
43
38
  name: '👩 Woman ♀️ 🇮🇹 it-IT-Neural2-A',
@@ -54,7 +49,6 @@ exports.GoogleVoiceOptions = [
54
49
  lang: 'it-IT',
55
50
  exampleUrl: 'https://storage.googleapis.com/appingles-pro.appspot.com/voice_demos/google_it-IT-Neural2-C.mp3',
56
51
  },
57
- // Portuguese
58
52
  {
59
53
  provider: 'google',
60
54
  name: '👩 Woman ♀️ 🇧🇷 pt-BR-Neural2-C',
@@ -71,7 +65,6 @@ exports.GoogleVoiceOptions = [
71
65
  lang: 'pt-BR',
72
66
  exampleUrl: 'https://storage.googleapis.com/appingles-pro.appspot.com/voice_demos/google_pt-BR-Neural2-B.mp3',
73
67
  },
74
- // Spanish
75
68
  {
76
69
  provider: 'google',
77
70
  name: '👨‍🦰 Man 🇲🇽 es-US-Neural2-B',
@@ -128,7 +121,6 @@ exports.GoogleVoiceOptions = [
128
121
  lang: 'es-ES',
129
122
  exampleUrl: 'https://storage.googleapis.com/appingles-pro.appspot.com/voice_demos/google_es-ES-Neural2-E.mp3',
130
123
  },
131
- // English
132
124
  {
133
125
  provider: 'google',
134
126
  name: '👩 Woman ♀️ 🇺🇸 en-US-Journey-F',
@@ -202,9 +194,7 @@ exports.GoogleVoiceOptions = [
202
194
  exampleUrl: 'https://storage.googleapis.com/appingles-pro.appspot.com/voice_demos/google_en-US-Neural2-I.mp3',
203
195
  },
204
196
  ];
205
- var TTSDto = /** @class */ (function () {
206
- function TTSDto() {
207
- }
208
- return TTSDto;
209
- }());
197
+ class TTSDto {
198
+ }
210
199
  exports.TTSDto = TTSDto;
200
+ //# sourceMappingURL=tts.classes.js.map