From 8e69d30aeb7bb62f35efd97165b1ee6b29478823 Mon Sep 17 00:00:00 2001 From: Amruth-Vamshi <130033232+Amruth-Vamshi@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:20:00 +0530 Subject: [PATCH] Added genderAudio parameter (#30) --- src/app.controller.ts | 8 +++++--- src/modules/aiTools/ai-tools.service.ts | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app.controller.ts b/src/app.controller.ts index e75138a..86be616 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -224,7 +224,7 @@ export class AppController { schemeName: promptDto.schemeName && promptDto.schemeName.trim() !== "" ? promptDto.schemeName - : "PM Kisan", + : "All Schemes", }; let conversation = await this.conversationService.getConversationState( @@ -502,7 +502,8 @@ export class AppController { }; res["audio"] = await this.aiToolsService.textToSpeech( res.text, - prompt.inputLanguage + prompt.inputLanguage, + promptDto.audioGender ); if (res["audio"]["error"]) { await this.telemetryService.capture({ @@ -1135,7 +1136,8 @@ export class AppController { textToaudio = removeLinks(textToaudio); result["audio"] = await this.aiToolsService.textToSpeech( textToaudio, - isNumber ? Language.en : prompt.inputLanguage + isNumber ? Language.en : prompt.inputLanguage, + promptDto.audioGender ); if (result["audio"]["error"]) { await this.telemetryService.capture({ diff --git a/src/modules/aiTools/ai-tools.service.ts b/src/modules/aiTools/ai-tools.service.ts index 8bdec67..8dd698b 100644 --- a/src/modules/aiTools/ai-tools.service.ts +++ b/src/modules/aiTools/ai-tools.service.ts @@ -182,7 +182,7 @@ export class AiToolsService { } } - async textToSpeech(text: string, language: Language) { + async textToSpeech(text: string, language: Language, audioGender: string = 'male') { try { let config: any = await this.getBhashiniConfig("tts", { language: { @@ -199,6 +199,7 @@ export class AiToolsService { language: { sourceLanguage: language, }, + gender: audioGender }, { input: [ @@ -385,7 +386,9 @@ export class AiToolsService { myHeaders.append("Content-Type", "application/json"); config["serviceId"] = serviceId; if (task == "tts") { - config["gender"] = "male"; + if(!config["gender"]){ + config["gender"] = "male"; + } config["samplingRate"] = 8000; } var raw = JSON.stringify({