mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Get realistic voice id from user personalization table
This commit is contained in:
parent
2e47b0879c
commit
1af5af0e97
1 changed files with 6 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ import { shouldSynthesize } from '../services/speech'
|
|||
import { readPushSubscription } from '../datalayer/pubsub'
|
||||
import { AppDataSource } from '../server'
|
||||
import { enqueueTextToSpeech } from '../utils/createTask'
|
||||
import { UserPersonalization } from '../entity/user_personalization'
|
||||
|
||||
const logger = buildLogger('app.dispatch')
|
||||
|
||||
|
|
@ -56,12 +57,15 @@ export function textToSpeechRouter() {
|
|||
// checks if this page needs to be synthesized automatically
|
||||
if (await shouldSynthesize(userId, page)) {
|
||||
logger.info('page needs to be synthesized')
|
||||
const userPersonalization = await getRepository(
|
||||
UserPersonalization
|
||||
).findOneBy({ user: { id: userId } })
|
||||
// initialize state
|
||||
const speech = await getRepository(Speech).save({
|
||||
user: { id: userId },
|
||||
elasticPageId: id,
|
||||
state: SpeechState.INITIALIZED,
|
||||
voice: 'en-US-JennyNeural',
|
||||
voice: userPersonalization?.speechVoice || 'Harrison',
|
||||
})
|
||||
// enqueue a task to convert text to speech
|
||||
const taskName = await enqueueTextToSpeech({
|
||||
|
|
@ -70,6 +74,7 @@ export function textToSpeechRouter() {
|
|||
text: page.content,
|
||||
voice: speech.voice,
|
||||
priority: 'low',
|
||||
isUltraRealisticVoice: true,
|
||||
})
|
||||
logger.info('Start Text to speech task', { taskName })
|
||||
return res.status(202).send('Text to speech task started')
|
||||
|
|
|
|||
Loading…
Reference in a new issue