Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/server/src/controllers/text-to-speech/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ const generateTextToSpeech = async (req: Request, res: Response) => {
let provider: string, credentialId: string, voice: string, model: string

if (chatflowId) {
const workspaceId = req.user?.activeWorkspaceId
let workspaceId = req.user?.activeWorkspaceId
let chatflow: Awaited<ReturnType<typeof chatflowsService.getChatflowById>>

if (workspaceId) {
chatflow = await chatflowsService.getChatflowById(chatflowId, workspaceId)
} else {
// Fallback: get workspaceId from chatflow when req.user.activeWorkspaceId is not set (from whitelist API)
chatflow = await chatflowsService.getChatflowById(chatflowId)
workspaceId = chatflow.workspaceId
}
Comment thread
yau-wd marked this conversation as resolved.

if (!workspaceId) {
throw new InternalFlowiseError(
StatusCodes.NOT_FOUND,
`Error: textToSpeechController.generateTextToSpeech - workspace ${workspaceId} not found!`
`Error: textToSpeechController.generateTextToSpeech - workspace not found!`
)
}
// Get TTS config from chatflow
const chatflow = await chatflowsService.getChatflowById(chatflowId, workspaceId)
const ttsConfig = JSON.parse(chatflow.textToSpeech)

// Find the provider with status: true
Expand Down