diff --git a/packages/server/src/controllers/internal-predictions/index.ts b/packages/server/src/controllers/internal-predictions/index.ts index 48ace57fb..5e53a1d65 100644 --- a/packages/server/src/controllers/internal-predictions/index.ts +++ b/packages/server/src/controllers/internal-predictions/index.ts @@ -3,7 +3,6 @@ import { utilBuildChatflow } from '../../utils/buildChatflow' import { getRunningExpressApp } from '../../utils/getRunningExpressApp' import { getErrorMessage } from '../../errors/utils' import { MODE } from '../../Interface' -import { generateTTSForResponseStream, shouldAutoPlayTTS } from '../../utils/buildChatflow' // Send input message and get prediction result (Internal) const createInternalPrediction = async (req: Request, res: Response, next: NextFunction) => { @@ -39,26 +38,6 @@ const createAndStreamInternalPrediction = async (req: Request, res: Response, ne const apiResponse = await utilBuildChatflow(req, true) sseStreamer.streamMetadataEvent(apiResponse.chatId, apiResponse) - - const chatflow = req.body.chatflow || req.body - if (shouldAutoPlayTTS(chatflow.textToSpeech) && apiResponse.text) { - const options = { - orgId: req.body.orgId || '', - chatflowid: req.body.chatflowid || '', - chatId: apiResponse.chatId, - appDataSource: getRunningExpressApp().AppDataSource, - databaseEntities: getRunningExpressApp().AppDataSource?.entityMetadatas || [] - } - - await generateTTSForResponseStream( - apiResponse.text, - chatflow.textToSpeech, - options, - apiResponse.chatId, - apiResponse.chatMessageId, - sseStreamer - ) - } } catch (error) { if (chatId) { sseStreamer.streamErrorEvent(chatId, getErrorMessage(error)) diff --git a/packages/server/src/controllers/predictions/index.ts b/packages/server/src/controllers/predictions/index.ts index 47cc27c99..02dbfeee3 100644 --- a/packages/server/src/controllers/predictions/index.ts +++ b/packages/server/src/controllers/predictions/index.ts @@ -77,26 +77,6 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction) const apiResponse = await predictionsServices.buildChatflow(req) sseStreamer.streamMetadataEvent(apiResponse.chatId, apiResponse) - - const chatflow = await chatflowsService.getChatflowById(req.params.id) - if (chatflow && shouldAutoPlayTTS(chatflow.textToSpeech) && apiResponse.text) { - const options = { - orgId: req.body.orgId || '', - chatflowid: req.params.id, - chatId: apiResponse.chatId, - appDataSource: getRunningExpressApp().AppDataSource, - databaseEntities: getRunningExpressApp().AppDataSource?.entityMetadatas || [] - } - - await generateTTSForResponseStream( - apiResponse.text, - chatflow.textToSpeech, - options, - apiResponse.chatId, - apiResponse.chatMessageId, - sseStreamer - ) - } } catch (error) { if (chatId) { sseStreamer.streamErrorEvent(chatId, getErrorMessage(error)) diff --git a/packages/server/src/utils/buildAgentflow.ts b/packages/server/src/utils/buildAgentflow.ts index bf6c16f5c..d6a01e666 100644 --- a/packages/server/src/utils/buildAgentflow.ts +++ b/packages/server/src/utils/buildAgentflow.ts @@ -2180,6 +2180,7 @@ export const executeAgentFlow = async ({ if (sessionId) result.sessionId = sessionId if (shouldAutoPlayTTS(chatflow.textToSpeech) && result.text) { + logger.info('Generating TTS for response in executeAgentFlow') const options = { orgId, chatflowid, diff --git a/packages/server/src/utils/buildChatflow.ts b/packages/server/src/utils/buildChatflow.ts index 9c5babc04..72d97173d 100644 --- a/packages/server/src/utils/buildChatflow.ts +++ b/packages/server/src/utils/buildChatflow.ts @@ -899,6 +899,7 @@ export const executeFlow = async ({ if (Object.keys(setVariableNodesOutput).length) result.flowVariables = setVariableNodesOutput if (shouldAutoPlayTTS(chatflow.textToSpeech) && result.text) { + logger.info('Generating TTS for response in executeFlow') const options = { orgId, chatflowid,