Escape entityName in ssml

This commit is contained in:
Hongbo Wu 2022-09-07 23:13:12 +08:00
parent 967fb3c6d5
commit 68a932ad0b
2 changed files with 3 additions and 2 deletions

View file

@ -8,6 +8,7 @@ import {
SpeechSynthesizer,
} from 'microsoft-cognitiveservices-speech-sdk'
import { endSsml, htmlToSsmlItems, ssmlItemText, startSsml } from './htmlToSsml'
import * as _ from 'underscore'
export interface TextToSpeechInput {
text: string
@ -150,7 +151,7 @@ export const synthesizeTextToSpeech = async (
// for utterance
const start = startSsml(ssmlOptions)
wordOffset = -start.length
const ssml = `${start}${input.text}${endSsml()}`
const ssml = `${start}${_.escape(input.text)}${endSsml()}`
const result = await speakSsmlAsyncPromise(ssml)
return {
audioData: Buffer.from(result.audioData),

View file

@ -7,7 +7,7 @@ describe('htmlToSsmlItems', () => {
primaryVoice: 'test-primary',
secondaryVoice: 'test-secondary',
language: 'en-US',
rate: 1,
rate: '1.0',
}
describe('a simple html file', () => {