@dataclouder/conversation-card-nestjs 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/dist/libs/conversation-cards/src/clases/conversation.interface.d.ts +160 -0
  2. package/dist/libs/conversation-cards/src/clases/conversation.interface.js +40 -0
  3. package/dist/libs/conversation-cards/src/clases/conversation.interface.js.map +1 -0
  4. package/dist/libs/conversation-cards/src/conversation-ai.controller.d.ts +20 -0
  5. package/dist/libs/conversation-cards/src/conversation-ai.controller.js +151 -0
  6. package/dist/libs/conversation-cards/src/conversation-ai.controller.js.map +1 -0
  7. package/dist/libs/conversation-cards/src/conversation-ai.module.d.ts +2 -0
  8. package/dist/libs/conversation-cards/src/conversation-ai.module.js +27 -0
  9. package/dist/libs/conversation-cards/src/conversation-ai.module.js.map +1 -0
  10. package/dist/libs/conversation-cards/src/conversation-ai.service.d.ts +17 -0
  11. package/dist/libs/conversation-cards/src/conversation-ai.service.js +105 -0
  12. package/dist/libs/conversation-cards/src/conversation-ai.service.js.map +1 -0
  13. package/dist/libs/conversation-cards/src/conversation-cards.module.d.ts +2 -0
  14. package/dist/libs/conversation-cards/src/conversation-cards.module.js +27 -0
  15. package/dist/libs/conversation-cards/src/conversation-cards.module.js.map +1 -0
  16. package/dist/libs/conversation-cards/src/conversation-cards.service.d.ts +2 -0
  17. package/dist/libs/conversation-cards/src/conversation-cards.service.js +17 -0
  18. package/dist/libs/conversation-cards/src/conversation-cards.service.js.map +1 -0
  19. package/dist/libs/conversation-cards/src/conversation.controller.d.ts +3 -0
  20. package/dist/libs/conversation-cards/src/conversation.controller.js +33 -0
  21. package/dist/libs/conversation-cards/src/conversation.controller.js.map +1 -0
  22. package/dist/libs/conversation-cards/src/dto/create-conversation.dto.d.ts +17 -0
  23. package/dist/libs/conversation-cards/src/dto/create-conversation.dto.js +42 -0
  24. package/dist/libs/conversation-cards/src/dto/create-conversation.dto.js.map +1 -0
  25. package/dist/libs/conversation-cards/src/entities/conversation.entity.d.ts +67 -0
  26. package/dist/libs/conversation-cards/src/entities/conversation.entity.js +97 -0
  27. package/dist/libs/conversation-cards/src/entities/conversation.entity.js.map +1 -0
  28. package/dist/libs/conversation-cards/src/index.d.ts +2 -0
  29. package/dist/libs/conversation-cards/src/index.js +19 -0
  30. package/dist/libs/conversation-cards/src/index.js.map +1 -0
  31. package/dist/libs/conversation-cards/src/tts/tts-service.d.ts +20 -0
  32. package/dist/libs/conversation-cards/src/tts/tts-service.js +124 -0
  33. package/dist/libs/conversation-cards/src/tts/tts-service.js.map +1 -0
  34. package/dist/libs/conversation-cards/src/tts/tts.classes.d.ts +32 -0
  35. package/dist/libs/conversation-cards/src/tts/tts.classes.js +200 -0
  36. package/dist/libs/conversation-cards/src/tts/tts.classes.js.map +1 -0
  37. package/dist/libs/conversation-cards/src/tts/voices.d.ts +3 -0
  38. package/dist/libs/conversation-cards/src/tts/voices.js +208 -0
  39. package/dist/libs/conversation-cards/src/tts/voices.js.map +1 -0
  40. package/dist/src/common/app-exception.d.ts +28 -0
  41. package/dist/src/common/app-exception.js +28 -0
  42. package/dist/src/common/app-exception.js.map +1 -0
  43. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  44. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ "use strict";
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;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ConversationAiController = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const swagger_1 = require("@nestjs/swagger");
15
+ let ConversationAiController = class ConversationAiController {
16
+ async getCards() {
17
+ return 'Hello World';
18
+ }
19
+ };
20
+ exports.ConversationAiController = ConversationAiController;
21
+ __decorate([
22
+ (0, common_1.Get)('/cards'),
23
+ (0, swagger_1.ApiOperation)({ summary: 'Get the cards' }),
24
+ (0, swagger_1.ApiResponse)({ status: 200, description: 'Return the cards.' }),
25
+ __metadata("design:type", Function),
26
+ __metadata("design:paramtypes", []),
27
+ __metadata("design:returntype", Promise)
28
+ ], ConversationAiController.prototype, "getCards", null);
29
+ exports.ConversationAiController = ConversationAiController = __decorate([
30
+ (0, swagger_1.ApiTags)('conversation-cards-library'),
31
+ (0, common_1.Controller)('api/conversation-cards-library')
32
+ ], ConversationAiController);
33
+ //# sourceMappingURL=conversation.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.controller.js","sourceRoot":"","sources":["../../../../src/conversation.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,6CAAqE;AAI9D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAI7B,AAAN,KAAK,CAAC,QAAQ;QACZ,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAA;AAPY,4DAAwB;AAI7B;IAHL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;IAC1C,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;;;;wDAG9D;mCANU,wBAAwB;IAFpC,IAAA,iBAAO,EAAC,4BAA4B,CAAC;IACrC,IAAA,mBAAU,EAAC,gCAAgC,CAAC;GAChC,wBAAwB,CAOpC"}
@@ -0,0 +1,17 @@
1
+ import { ChatMessage, ConversationType } from '../clases/conversation.interface';
2
+ export declare class CreateConversationDto {
3
+ message: string;
4
+ userId: string;
5
+ context?: Record<string, any>;
6
+ }
7
+ export declare class ConversationDTO {
8
+ id?: string;
9
+ entityId?: string;
10
+ type?: ConversationType;
11
+ createdAt?: Date;
12
+ messages: Array<ChatMessage>;
13
+ transcription?: boolean;
14
+ modelName?: string;
15
+ provider?: string;
16
+ returnJson?: boolean;
17
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
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;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ConversationDTO = exports.CreateConversationDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ class CreateConversationDto {
15
+ }
16
+ exports.CreateConversationDto = CreateConversationDto;
17
+ __decorate([
18
+ (0, swagger_1.ApiProperty)({
19
+ description: 'The message content of the conversation',
20
+ example: 'Hello, how can I help you today?',
21
+ }),
22
+ __metadata("design:type", String)
23
+ ], CreateConversationDto.prototype, "message", void 0);
24
+ __decorate([
25
+ (0, swagger_1.ApiProperty)({
26
+ description: 'The user ID associated with the conversation',
27
+ example: 'user123',
28
+ }),
29
+ __metadata("design:type", String)
30
+ ], CreateConversationDto.prototype, "userId", void 0);
31
+ __decorate([
32
+ (0, swagger_1.ApiProperty)({
33
+ description: 'Additional context for the conversation',
34
+ required: false,
35
+ example: { previousContext: 'User asked about weather' },
36
+ }),
37
+ __metadata("design:type", Object)
38
+ ], CreateConversationDto.prototype, "context", void 0);
39
+ class ConversationDTO {
40
+ }
41
+ exports.ConversationDTO = ConversationDTO;
42
+ //# sourceMappingURL=create-conversation.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-conversation.dto.js","sourceRoot":"","sources":["../../../../../src/dto/create-conversation.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6CAA8C;AAG9C,MAAa,qBAAqB;CAmBjC;AAnBD,sDAmBC;AAdC;IAJC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,yCAAyC;QACtD,OAAO,EAAE,kCAAkC;KAC5C,CAAC;;sDACc;AAMhB;IAJC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,8CAA8C;QAC3D,OAAO,EAAE,SAAS;KACnB,CAAC;;qDACa;AAOf;IALC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,yCAAyC;QACtD,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,EAAE,eAAe,EAAE,0BAA0B,EAAE;KACzD,CAAC;;sDAC4B;AAGhC,MAAa,eAAe;CAU3B;AAVD,0CAUC"}
@@ -0,0 +1,67 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ /// <reference types="mongoose/types/inferrawdoctype" />
26
+ import { Document, Schema as MongooseSchema } from 'mongoose';
27
+ import { ConversationType, TextEngines, IConversationCard, CharacterCardDC } from '../clases/conversation.interface';
28
+ export type ConversationDocument = Conversation & Document;
29
+ export declare class Conversation implements IConversationCard {
30
+ _id: MongooseSchema.Types.ObjectId;
31
+ id: string;
32
+ version: string;
33
+ title: string;
34
+ characterCard: CharacterCardDC;
35
+ textEngine: TextEngines;
36
+ conversationType: ConversationType;
37
+ lang: string;
38
+ assets: {
39
+ image: any;
40
+ };
41
+ tts: {
42
+ voice: string;
43
+ secondaryVoice: string;
44
+ speed: string;
45
+ speedRate: number;
46
+ };
47
+ voice: string;
48
+ secondaryVoice: string;
49
+ speed: string;
50
+ speedRate: number;
51
+ metaApp: {
52
+ isPublished: boolean;
53
+ isPublic: boolean;
54
+ authorId: string;
55
+ authorEmail: string;
56
+ createdAt: Date;
57
+ updatedAt: Date;
58
+ takenCount: number;
59
+ };
60
+ createdAt: Date;
61
+ updatedAt: Date;
62
+ }
63
+ export declare const ConversationSchema: MongooseSchema<Conversation, import("mongoose").Model<Conversation, any, any, any, Document<unknown, any, Conversation> & Conversation & Required<{
64
+ _id: MongooseSchema.Types.ObjectId;
65
+ }>, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Conversation, Document<unknown, {}, import("mongoose").FlatRecord<Conversation>> & import("mongoose").FlatRecord<Conversation> & Required<{
66
+ _id: MongooseSchema.Types.ObjectId;
67
+ }>>;
@@ -0,0 +1,97 @@
1
+ "use strict";
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;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ConversationSchema = exports.Conversation = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const mongoose_2 = require("mongoose");
15
+ const conversation_interface_1 = require("../clases/conversation.interface");
16
+ let Conversation = class Conversation {
17
+ };
18
+ exports.Conversation = Conversation;
19
+ __decorate([
20
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, auto: true }),
21
+ __metadata("design:type", mongoose_2.Schema.Types.ObjectId)
22
+ ], Conversation.prototype, "_id", void 0);
23
+ __decorate([
24
+ (0, mongoose_1.Prop)(),
25
+ __metadata("design:type", String)
26
+ ], Conversation.prototype, "id", void 0);
27
+ __decorate([
28
+ (0, mongoose_1.Prop)({ required: false }),
29
+ __metadata("design:type", String)
30
+ ], Conversation.prototype, "version", void 0);
31
+ __decorate([
32
+ (0, mongoose_1.Prop)({ required: false }),
33
+ __metadata("design:type", String)
34
+ ], Conversation.prototype, "title", void 0);
35
+ __decorate([
36
+ (0, mongoose_1.Prop)({ type: Object, required: false }),
37
+ __metadata("design:type", Object)
38
+ ], Conversation.prototype, "characterCard", void 0);
39
+ __decorate([
40
+ (0, mongoose_1.Prop)({ required: true, enum: conversation_interface_1.TextEngines }),
41
+ __metadata("design:type", String)
42
+ ], Conversation.prototype, "textEngine", void 0);
43
+ __decorate([
44
+ (0, mongoose_1.Prop)({ required: true, enum: conversation_interface_1.ConversationType }),
45
+ __metadata("design:type", String)
46
+ ], Conversation.prototype, "conversationType", void 0);
47
+ __decorate([
48
+ (0, mongoose_1.Prop)({ required: false }),
49
+ __metadata("design:type", String)
50
+ ], Conversation.prototype, "lang", void 0);
51
+ __decorate([
52
+ (0, mongoose_1.Prop)({ type: Object, required: false }),
53
+ __metadata("design:type", Object)
54
+ ], Conversation.prototype, "assets", void 0);
55
+ __decorate([
56
+ (0, mongoose_1.Prop)({ type: Object, required: false }),
57
+ __metadata("design:type", Object)
58
+ ], Conversation.prototype, "tts", void 0);
59
+ __decorate([
60
+ (0, mongoose_1.Prop)({ required: false }),
61
+ __metadata("design:type", String)
62
+ ], Conversation.prototype, "voice", void 0);
63
+ __decorate([
64
+ (0, mongoose_1.Prop)({ required: false }),
65
+ __metadata("design:type", String)
66
+ ], Conversation.prototype, "secondaryVoice", void 0);
67
+ __decorate([
68
+ (0, mongoose_1.Prop)({ required: false }),
69
+ __metadata("design:type", String)
70
+ ], Conversation.prototype, "speed", void 0);
71
+ __decorate([
72
+ (0, mongoose_1.Prop)({ required: false }),
73
+ __metadata("design:type", Number)
74
+ ], Conversation.prototype, "speedRate", void 0);
75
+ __decorate([
76
+ (0, mongoose_1.Prop)({ type: Object, required: false }),
77
+ __metadata("design:type", Object)
78
+ ], Conversation.prototype, "metaApp", void 0);
79
+ __decorate([
80
+ (0, mongoose_1.Prop)(),
81
+ __metadata("design:type", Date)
82
+ ], Conversation.prototype, "createdAt", void 0);
83
+ __decorate([
84
+ (0, mongoose_1.Prop)(),
85
+ __metadata("design:type", Date)
86
+ ], Conversation.prototype, "updatedAt", void 0);
87
+ exports.Conversation = Conversation = __decorate([
88
+ (0, mongoose_1.Schema)({ timestamps: true })
89
+ ], Conversation);
90
+ exports.ConversationSchema = mongoose_1.SchemaFactory.createForClass(Conversation);
91
+ exports.ConversationSchema.pre('save', function (next) {
92
+ if (this.isNew) {
93
+ this.id = this._id.toString();
94
+ }
95
+ next();
96
+ });
97
+ //# sourceMappingURL=conversation.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.entity.js","sourceRoot":"","sources":["../../../../../src/entities/conversation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA+D;AAC/D,uCAA8D;AAC9D,6EAAqH;AAK9G,IAAM,YAAY,GAAlB,MAAM,YAAY;CAkExB,CAAA;AAlEY,oCAAY;AAEvB;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,iBAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;8BACrD,iBAAc,CAAC,KAAK,CAAC,QAAQ;yCAAC;AAGnC;IADC,IAAA,eAAI,GAAE;;wCACI;AAGX;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;6CACV;AAGhB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;2CACZ;AAGd;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;mDACT;AAG/B;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,oCAAW,EAAE,CAAC;;gDACpB;AAGxB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,yCAAgB,EAAE,CAAC;;sDACd;AAGnC;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;0CACb;AAGb;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;4CAGtC;AAGF;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;yCAMtC;AAGF;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;2CACZ;AAGd;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;oDACH;AAGvB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;2CACZ;AAGd;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;+CACR;AAGlB;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;6CAStC;AAGF;IADC,IAAA,eAAI,GAAE;8BACI,IAAI;+CAAC;AAGhB;IADC,IAAA,eAAI,GAAE;8BACI,IAAI;+CAAC;uBAjEL,YAAY;IADxB,IAAA,iBAAM,EAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;GAChB,YAAY,CAkExB;AAEY,QAAA,kBAAkB,GAAG,wBAAa,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAE7E,0BAAkB,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,IAAI;IAC3C,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;KAC/B;IACD,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './conversation-cards.module';
2
+ export * from './conversation-cards.service';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./conversation-cards.module"), exports);
18
+ __exportStar(require("./conversation-cards.service"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,+DAA6C"}
@@ -0,0 +1,20 @@
1
+ /// <reference types="node" />
2
+ import { SynthAudioOptions } from './tts.classes';
3
+ export interface TTSOptions {
4
+ voiceName: string;
5
+ text: string;
6
+ options: SynthAudioOptions;
7
+ lang: string;
8
+ isSsml: boolean;
9
+ }
10
+ export declare class TTSService {
11
+ private client;
12
+ constructor();
13
+ getSpeech(tts: TTSOptions): Promise<{
14
+ audioContent: Buffer;
15
+ voiceName: string;
16
+ }>;
17
+ private getSpeedRate;
18
+ listVoices(languageCode?: string): Promise<void>;
19
+ textToWav(voiceName: string, text: string): Promise<void>;
20
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
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;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TTSService = void 0;
13
+ const textToSpeech = require("@google-cloud/text-to-speech");
14
+ const tts_classes_1 = require("./tts.classes");
15
+ const app_exception_1 = require("src/common/app-exception");
16
+ const common_1 = require("@nestjs/common");
17
+ let TTSService = class TTSService {
18
+ constructor() {
19
+ try {
20
+ console.log('Initializing Text-to-Speech client');
21
+ this.client = new textToSpeech.TextToSpeechClient();
22
+ }
23
+ catch (error) {
24
+ console.error('Error initializing Text-to-Speech client:', error);
25
+ throw new app_exception_1.AppException({
26
+ error_message: 'Failed to initialize Text-to-Speech client',
27
+ explanation: 'Please ensure Google Cloud credentials are properly configured.',
28
+ exception: error,
29
+ });
30
+ }
31
+ }
32
+ async getSpeech(tts) {
33
+ console.log('Voice name:', tts.voiceName, 'Options:', tts.options, 'Lang:', tts.lang, 'is_ssml:', tts.isSsml);
34
+ let selectedVoiceName;
35
+ let languageCode;
36
+ if (!tts.voiceName) {
37
+ const voiceOptions = tts_classes_1.GoogleVoiceHQOptions.filter(voice => voice.lang.includes(tts.lang));
38
+ const voiceData = voiceOptions[Math.floor(Math.random() * voiceOptions.length)];
39
+ selectedVoiceName = voiceData.id;
40
+ languageCode = voiceData.lang;
41
+ }
42
+ else {
43
+ const voice = tts_classes_1.GoogleVoiceOptions.find(item => item.id === tts.voiceName);
44
+ if (!voice) {
45
+ throw new app_exception_1.AppException({ error_message: `Voice ${tts.voiceName} not found` });
46
+ }
47
+ selectedVoiceName = tts.voiceName;
48
+ languageCode = voice.lang;
49
+ }
50
+ let speakingRate = 1;
51
+ if (tts.options && !selectedVoiceName.includes('Journey')) {
52
+ speakingRate = tts.options.speed_rate && tts.options.speed_rate > 0 ? tts.options.speed_rate : this.getSpeedRate(tts.options?.speed);
53
+ }
54
+ const request = {
55
+ input: tts.isSsml ? { ssml: tts.text } : { text: tts.text },
56
+ voice: {
57
+ languageCode: languageCode,
58
+ name: selectedVoiceName,
59
+ },
60
+ audioConfig: {
61
+ audioEncoding: 'MP3',
62
+ speakingRate: speakingRate,
63
+ },
64
+ };
65
+ const [response] = await this.client.synthesizeSpeech(request);
66
+ return {
67
+ audioContent: response.audioContent,
68
+ voiceName: selectedVoiceName,
69
+ };
70
+ }
71
+ getSpeedRate(speed) {
72
+ switch (speed) {
73
+ case tts_classes_1.AudioSpeed.VeryFast:
74
+ return 1.5;
75
+ case tts_classes_1.AudioSpeed.Fast:
76
+ return 1.25;
77
+ case tts_classes_1.AudioSpeed.Regular:
78
+ return 1.0;
79
+ case tts_classes_1.AudioSpeed.Slow:
80
+ return 0.75;
81
+ case tts_classes_1.AudioSpeed.VerySlow:
82
+ return 0.5;
83
+ default:
84
+ return 1.0;
85
+ }
86
+ }
87
+ async listVoices(languageCode = 'en-US') {
88
+ const [response] = await this.client.listVoices({ languageCode });
89
+ const voices = response.voices?.sort((a, b) => a.name.localeCompare(b.name)) || [];
90
+ console.log(` Voices: ${voices.length} `.padStart(60, '-').padEnd(60, '-'));
91
+ voices.forEach(voice => {
92
+ const languages = voice.languageCodes?.join(', ') || '';
93
+ const name = voice.name;
94
+ const gender = voice.ssmlGender;
95
+ const rate = voice.naturalSampleRateHertz;
96
+ console.log(`${languages} | ${name} | ${gender} | ${rate?.toLocaleString()} Hz`);
97
+ });
98
+ }
99
+ async textToWav(voiceName, text) {
100
+ const languageCode = voiceName.split('-').slice(0, 2).join('-');
101
+ const request = {
102
+ input: { text: text },
103
+ voice: {
104
+ languageCode: languageCode,
105
+ name: voiceName,
106
+ },
107
+ audioConfig: {
108
+ audioEncoding: 'LINEAR16',
109
+ pitch: -1.0,
110
+ speakingRate: 0.9,
111
+ },
112
+ };
113
+ const [response] = await this.client.synthesizeSpeech(request);
114
+ console.log(response);
115
+ const filename = `${languageCode}.wav`;
116
+ console.log(`Generated speech saved to "${filename}"`);
117
+ }
118
+ };
119
+ exports.TTSService = TTSService;
120
+ exports.TTSService = TTSService = __decorate([
121
+ (0, common_1.Injectable)(),
122
+ __metadata("design:paramtypes", [])
123
+ ], TTSService);
124
+ //# sourceMapping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,CAAC;YAE1C,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,MAAM,IAAI,MAAM,MAAM,MAAM,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;QACnF,CAAC,CAAC,CAAC;IACL,CAAC;IAGD,KAAK,CAAC,SAAS,CAAC,SAAiB,EAAE,IAAY;QAC7C,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEhE,MAAM,OAAO,GAA8E;YACzF,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;YACrB,KAAK,EAAE;gBACL,YAAY,EAAE,YAAY;gBAC1B,IAAI,EAAE,SAAS;aAChB;YACD,WAAW,EAAE;gBACX,aAAa,EAAE,UAAU;gBACzB,KAAK,EAAE,CAAC,GAAG;gBACX,YAAY,EAAE,GAAG;aAClB;SACF,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEtB,MAAM,QAAQ,GAAG,GAAG,YAAY,MAAM,CAAC;QAOvC,OAAO,CAAC,GAAG,CAAC,8BAA8B,QAAQ,GAAG,CAAC,CAAC;IACzD,CAAC;CACF,CAAA;AArIY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;;GACA,UAAU,CAqItB"}
@@ -0,0 +1,32 @@
1
+ export declare enum AudioSpeed {
2
+ VerySlow = "VerySlow",
3
+ Slow = "Slow",
4
+ Regular = "Regular",
5
+ Fast = "Fast",
6
+ VeryFast = "VeryFast"
7
+ }
8
+ export declare enum VoiceCode {
9
+ MX = "MX"
10
+ }
11
+ export declare const GoogleVoiceHQOptions: VoiceOption[];
12
+ export declare const GoogleVoiceOptions: VoiceOption[];
13
+ export interface SynthAudioOptions {
14
+ speed?: AudioSpeed;
15
+ speed_rate?: number;
16
+ }
17
+ export interface VoiceOption {
18
+ id: string;
19
+ lang: string;
20
+ name?: string;
21
+ provider?: string;
22
+ gender?: string;
23
+ exampleUrl?: string;
24
+ }
25
+ export declare class TTSDto {
26
+ text: string;
27
+ ssml: boolean;
28
+ voice: string;
29
+ speed: AudioSpeed;
30
+ speedRate: number;
31
+ generateTranscription: boolean;
32
+ }