diff --git a/packages/text-to-speech/src/htmlToSsml.ts b/packages/text-to-speech/src/htmlToSsml.ts
index be3f1c2e8..e6c1207d6 100644
--- a/packages/text-to-speech/src/htmlToSsml.ts
+++ b/packages/text-to-speech/src/htmlToSsml.ts
@@ -178,6 +178,10 @@ function emitElement(
}
if (child.nodeType == 1 /* Node.ELEMENT_NODE */) {
maxVisitedIdx = emitElement(textItems, child as HTMLElement, false)
+ if (child.nodeName === 'LI') {
+ // add a new line after each list item
+ emit(textItems, '\n')
+ }
}
}
diff --git a/packages/text-to-speech/test/fixtures/blockquote.html b/packages/text-to-speech/test/fixtures/blockquote.html
new file mode 100644
index 000000000..1f4f016de
--- /dev/null
+++ b/packages/text-to-speech/test/fixtures/blockquote.html
@@ -0,0 +1 @@
+
Just for curiosity, how do you pick the articles for Slow Chinese?
Any advice on finding opportunities to communicate in Chinese?
What are your tips to improve comprehension? I feel like I’m working on reading, listening, and speaking all at once, sometimes I feel like I’m just getting surface understanding.
I often feel I use the same words/phrases over and over and my short-term memory is weak, I live in a non-Chinese environment although I have many opportunities to practice Chinese and have no plans to travel to China.
I'm American-born Chinese, so I grew up with Chinese speaking parents, but I used English and home and in daily life. My listening is strong, everything else is weak. I'm in China currently studying in a Master's program. I'm probably about HSK5-6 in my vocabulary and reading comprehension. If you have any tips for picking up reading/speaking, I'd love to know.
diff --git a/packages/text-to-speech/test/htmlToSsml.test.ts b/packages/text-to-speech/test/htmlToSsml.test.ts
index 4f53bdaf4..a2673f465 100644
--- a/packages/text-to-speech/test/htmlToSsml.test.ts
+++ b/packages/text-to-speech/test/htmlToSsml.test.ts
@@ -15,6 +15,10 @@ const TEST_OPTIONS = {
rate: '1.0',
}
+const load = (filename: string) => {
+ return fs.readFileSync(path.join(__dirname, filename), 'utf8')
+}
+
describe('stripEmojis', () => {
it('strips emojis from text and removes the extra space', () => {
const text = '🥛The Big Short guy is back with a new prediction'
@@ -226,10 +230,8 @@ describe('htmlToSpeechFile', () => {
describe('convert HTML to Speech file', () => {
it('converts each to an utterance', () => {
- const html = fs.readFileSync(
- path.resolve(__dirname, './fixtures/li.html'),
- { encoding: 'utf-8' }
- )
+ const html = load('./fixtures/li.html')
+
const speechFile = htmlToSpeechFile({
content: html,
title: 'Wang Yi at the UN; Fu Zhenghua sentenced; Nvidia China sales',
@@ -290,4 +292,21 @@ describe('convert HTML to Speech file', () => {
'If terms of the original $12.5 billion financing package remain the same, bankers may struggle to sell the risky Twitter buyout debt just as credit markets begin to crack, with yields at multiyear highs, they’re potentially on the hook for hundreds of millions of dollars of losses on the unsecured portion alone should they try to unload it to investors.'
)
})
+
+ it('splits sentences correctly in a blockquote element', () => {
+ const html = load('./fixtures/blockquote.html')
+
+ const speechFile = htmlToSpeechFile({
+ content: html,
+ options: TEST_OPTIONS,
+ })
+
+ expect(speechFile.utterances).to.have.lengthOf(5)
+ expect(speechFile.utterances[0].text).to.eql(
+ 'Just for curiosity, how do you pick the articles for Slow Chinese? Any advice on finding opportunities to communicate in Chinese? What are your tips to improve comprehension? '
+ )
+ expect(speechFile.utterances[1].text).to.eql(
+ 'I feel like I’m working on reading, listening, and speaking all at once, sometimes I feel like I’m just getting surface understanding. '
+ )
+ })
})