File tree Expand file tree Collapse file tree
packages/server/src/controllers/text-to-speech Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments