From 710243e94ec8bacb0a757a41d04f9c362546346f Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 23 Sep 2022 14:19:29 +0800 Subject: [PATCH] Allow language in the query to override the page language in the speech file --- packages/api/src/routers/article_router.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/api/src/routers/article_router.ts b/packages/api/src/routers/article_router.ts index 5891c025f..f54222b36 100644 --- a/packages/api/src/routers/article_router.ts +++ b/packages/api/src/routers/article_router.ts @@ -28,6 +28,7 @@ interface SpeechInput { voice?: string secondaryVoice?: string priority?: 'low' | 'high' + language?: string } const outputFormats = ['mp3', 'speech-marks', 'speech'] const logger = buildLogger('app.dispatch') @@ -85,7 +86,8 @@ export function articleRouter() { async (req, res) => { const articleId = req.params.id const outputFormat = req.params.outputFormat - const { voice, priority, secondaryVoice } = req.query as SpeechInput + const { voice, priority, secondaryVoice, language } = + req.query as SpeechInput if (!articleId || outputFormats.indexOf(outputFormat) === -1) { return res.status(400).send('Invalid data') } @@ -117,7 +119,7 @@ export function articleRouter() { options: { primaryVoice: voice, secondaryVoice: secondaryVoice, - language: page.language, + language: language || page.language, }, }) return res.send({ ...speechFile, pageId: articleId })