diff --git a/src/app.controller.ts b/src/app.controller.ts index ddae3eb..1b311ac 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -5,7 +5,7 @@ import { interpret } from "xstate"; import { Language } from "./language"; import { ConfigService } from "@nestjs/config"; import { AiToolsService } from "./modules/aiTools/ai-tools.service"; -import { formatStringsToTable, wordToNumber } from "./common/utils"; +import { formatStringsToTable, removeLinks, wordToNumber } from "./common/utils"; import { ConversationService } from "./modules/conversation/conversation.service"; import { PrismaService } from "./global-services/prisma.service"; import { CustomLogger } from "./common/logger"; @@ -1010,6 +1010,7 @@ export class AppController { } // verboseLogger("textToaudio =",textToaudio) let audioStartTime = Date.now(); + textToaudio = removeLinks(textToaudio) result['audio'] = await this.aiToolsService.textToSpeech(textToaudio,isNumber ? Language.en : prompt.inputLanguage) if(result['audio']['error']){ await this.telemetryService.capture({ diff --git a/src/common/utils.ts b/src/common/utils.ts index 6091dc2..199690a 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -211,4 +211,12 @@ export const wordToNumber = (input,type='benId') => { return number + "th"; } } +} + +export const removeLinks = (inputString) => { + // Define a regular expression pattern for identifying links + var linkPattern = /http[s]?:\/\/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+/g; + // Use the replace() method to replace all links with an empty string + var resultString = inputString.replace(linkPattern, ''); + return resultString; } \ No newline at end of file diff --git a/src/xstate/prompt/prompt.machine.ts b/src/xstate/prompt/prompt.machine.ts index abdde6b..54af5fd 100644 --- a/src/xstate/prompt/prompt.machine.ts +++ b/src/xstate/prompt/prompt.machine.ts @@ -882,7 +882,8 @@ export const botFlowMachine3:any = actions: [ assign({ response: () => engMessage["message.convoStarter"], - type:"pause" + type:"pause", + isWadhwaniResponse: "false" }) ] }, @@ -899,7 +900,8 @@ export const botFlowMachine3:any = target: 'checkIfOTPHasBeenVerified', actions: [ assign({ - queryType: (_,event) => {console.log(`assigning queryType = ${event.data}`); return event.data} + queryType: (_,event) => {console.log(`assigning queryType = ${event.data}`); return event.data}, + isWadhwaniResponse: "false" }) ] } @@ -926,8 +928,7 @@ export const botFlowMachine3:any = userAadhaarNumber: "", lastAadhaarDigits: "", isOTPVerified: false, - type: '', - isWadhwaniResponse: "false" + type: '' }) ] }, @@ -939,8 +940,7 @@ export const botFlowMachine3:any = lastAadhaarDigits: "", isOTPVerified: false, error: (_, event) => event.data.message, - type: '', - isWadhwaniResponse: "false" + type: '' }) ] }