diff --git a/packages/api/src/routers/article_router.ts b/packages/api/src/routers/article_router.ts index 691c3c293..7915abc4f 100644 --- a/packages/api/src/routers/article_router.ts +++ b/packages/api/src/routers/article_router.ts @@ -150,10 +150,7 @@ export function articleRouter() { user: { id: uid }, elasticPageId: articleId, state: SpeechState.INITIALIZED, - voice: - voice || - userPersonalization?.speechVoice || - 'en-US-JennyMultilingualNeural', + voice: voice || userPersonalization?.speechVoice || 'en-US-JennyNeural', }) // enqueue a task to convert text to speech const taskName = await enqueueTextToSpeech(uid, speech.id) diff --git a/packages/api/src/utils/textToSpeech.ts b/packages/api/src/utils/textToSpeech.ts index 556f0b128..b75265743 100644 --- a/packages/api/src/utils/textToSpeech.ts +++ b/packages/api/src/utils/textToSpeech.ts @@ -20,6 +20,7 @@ export interface TextToSpeechInput { textType?: 'text' | 'ssml' rate?: number volume?: number + complimentaryVoice?: string } export interface TextToSpeechOutput { @@ -177,7 +178,7 @@ export const synthesizeTextToSpeech = async ( // use complimentary voice for blockquote, hardcoded for now const voice = htmlElement.tagName.toLowerCase() === 'blockquote' - ? 'en-US-AriaNeural' + ? input.complimentaryVoice || 'en-US-AriaNeural' : input.voice const ssml = htmlElementToSsml({ htmlElement: e, @@ -218,7 +219,7 @@ export const synthesizeTextToSpeech = async ( export const htmlElementToSsml = ({ htmlElement, language = 'en-US', - voice = 'en-US-JennyMultilingualNeural', + voice = 'en-US-JennyNeural', rate = 1, volume = 100, }: { diff --git a/packages/api/test/utils/textToSpeech.test.ts b/packages/api/test/utils/textToSpeech.test.ts index 2276b2ac4..e78492cca 100644 --- a/packages/api/test/utils/textToSpeech.test.ts +++ b/packages/api/test/utils/textToSpeech.test.ts @@ -35,7 +35,7 @@ describe('textToSpeech', () => { const htmlElement = parseHTML( `

Marry had a little lamb

` ).document.documentElement - const ssml = htmlElementToSsml(htmlElement) + const ssml = htmlElementToSsml({ htmlElement }) expect(ssml).to.equal( `

Marry had a little lamb

` )