Merge pull request #1229 from omnivore-app/feature/override-language-in-speech-file

Allow language in the query to override the page language in the speech file
This commit is contained in:
Jackson Harper 2022-09-24 11:33:50 +08:00 committed by GitHub
commit e65269b203
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 })