diff --git a/packages/api/src/routers/article_router.ts b/packages/api/src/routers/article_router.ts index 68e804071..487b32c77 100644 --- a/packages/api/src/routers/article_router.ts +++ b/packages/api/src/routers/article_router.ts @@ -73,13 +73,18 @@ export function articleRouter() { }) router.get( - '/:id/:outputFormat/:voice?', + '/:id/:outputFormat/:priority/:voice?', cors(corsConfig), async (req, res) => { const articleId = req.params.id const outputFormat = req.params.outputFormat const voice = req.params.voice - if (!articleId || !['mp3', 'speech-marks'].includes(outputFormat)) { + const priority = req.params.priority + if ( + !articleId || + !['mp3', 'speech-marks'].includes(outputFormat) || + !['low', 'high'].includes(priority) + ) { return res.status(400).send('Invalid data') } const token = req.cookies?.auth || req.headers?.authorization @@ -153,14 +158,13 @@ export function articleRouter() { voice: voice || userPersonalization?.speechVoice || 'en-US-JennyNeural', }) // enqueue a task to convert text to speech - const taskName = await enqueueTextToSpeech( - uid, - speech.id, - page.content, - 'ssml', - speech.voice, - env.fileUpload.gcsUploadBucket - ) + const taskName = await enqueueTextToSpeech({ + userId: uid, + speechId: speech.id, + text: page.content, + voice: speech.voice, + priority: priority as 'low' | 'high', + }) logger.info('Start Text to speech task', { taskName }) res.status(202).send('Text to speech task started') }