Fix tests

This commit is contained in:
Hongbo Wu 2022-08-24 18:07:59 +08:00
parent a477560626
commit 99a628f03f
3 changed files with 5 additions and 7 deletions

View file

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

View file

@ -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,
}: {

View file

@ -35,7 +35,7 @@ describe('textToSpeech', () => {
const htmlElement = parseHTML(
`<p data-omnivore-anchor-idx="1">Marry had a little lamb</p>`
).document.documentElement
const ssml = htmlElementToSsml(htmlElement)
const ssml = htmlElementToSsml({ htmlElement })
expect(ssml).to.equal(
`<speak xml:lang="en-US" xmlns="http://www.w3.org/2001/10/synthesis" version="1.0"><voice name="en-US-JennyNeural"><prosody volume="100" rate="1"><bookmark mark="data-omnivore-anchor-idx-1"></bookmark><p data-omnivore-anchor-idx="1">Marry had a little lamb</p></prosody></voice></speak>`
)