diff --git a/packages/api/src/routers/text_to_speech.ts b/packages/api/src/routers/text_to_speech.ts index dab71ac4e..8a89a3202 100644 --- a/packages/api/src/routers/text_to_speech.ts +++ b/packages/api/src/routers/text_to_speech.ts @@ -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')