Skip to content

Commit

Permalink
Added genderAudio parameter (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amruth-Vamshi authored Sep 3, 2024
1 parent 45e6e82 commit 8e69d30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down
7 changes: 5 additions & 2 deletions src/modules/aiTools/ai-tools.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -199,6 +199,7 @@ export class AiToolsService {
language: {
sourceLanguage: language,
},
gender: audioGender
},
{
input: [
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 8e69d30

Please sign in to comment.