mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add the priority to request param and use the correct queue accordingly
This commit is contained in:
parent
f903a92245
commit
4af340f30e
1 changed files with 14 additions and 10 deletions
|
|
@ -73,13 +73,18 @@ export function articleRouter() {
|
|||
})
|
||||
|
||||
router.get(
|
||||
'/:id/:outputFormat/:voice?',
|
||||
'/:id/:outputFormat/:priority/:voice?',
|
||||
cors<express.Request>(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')
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue