Skip to content

Commit 95297d3

Browse files
authored
Merge branch 'main' into bugfix/Image-References
2 parents 59bea86 + 9a772b6 commit 95297d3

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • packages/server/src/controllers/text-to-speech

packages/server/src/controllers/text-to-speech/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,24 @@ const generateTextToSpeech = async (req: Request, res: Response) => {
3030
let provider: string, credentialId: string, voice: string, model: string
3131

3232
if (chatflowId) {
33-
const workspaceId = req.user?.activeWorkspaceId
33+
let workspaceId = req.user?.activeWorkspaceId
34+
let chatflow: Awaited<ReturnType<typeof chatflowsService.getChatflowById>>
35+
36+
if (workspaceId) {
37+
chatflow = await chatflowsService.getChatflowById(chatflowId, workspaceId)
38+
} else {
39+
// Fallback: get workspaceId from chatflow when req.user.activeWorkspaceId is not set (from whitelist API)
40+
chatflow = await chatflowsService.getChatflowById(chatflowId)
41+
workspaceId = chatflow.workspaceId
42+
}
43+
3444
if (!workspaceId) {
3545
throw new InternalFlowiseError(
3646
StatusCodes.NOT_FOUND,
37-
`Error: textToSpeechController.generateTextToSpeech - workspace ${workspaceId} not found!`
47+
`Error: textToSpeechController.generateTextToSpeech - workspace not found!`
3848
)
3949
}
4050
// Get TTS config from chatflow
41-
const chatflow = await chatflowsService.getChatflowById(chatflowId, workspaceId)
4251
const ttsConfig = JSON.parse(chatflow.textToSpeech)
4352

4453
// Find the provider with status: true

0 commit comments

Comments
 (0)