microsoft / immersive-reader-sdk

SDK for using the Immersive Reader through Cognitive Services
MIT License
93 stars 52 forks source link

Read aloud stops at certain html content #483

Open cadi3s opened 8 months ago

cadi3s commented 8 months ago

Hi, reading aloud text works great, for both plain text and html chunks, except in one case. When I launch with a chunk with mimeType: 'text/html' and contents a shown below:

Removing the <p> tags from the content avoids the problem, but I would rather not do that. Can anyone confirm that this is a bug in the SDK ?

Sample html chunk

<p style="margin-bottom: 10px;">
    <span style="font-size: 12px;">Romeo and Juliet is a tragedy written by William Shakespeare early in his career about two young star-crossed lovers whose deaths ultimately reconcile their feuding families. It was among Shakespeare's most popular plays during his lifetime and along with Hamlet, is one of his most frequently performed plays. Today, the title characters are regarded as archetypal young lovers.</span>
</p>
<p style="margin-bottom: 10px;">
    <span style="font-size: 12px;">Romeo and Juliet belongs to a tradition of tragic romances stretching back to antiquity. The plot is based on an Italian tale translated into verse as The Tragical History of Romeus and Juliet by Arthur Brooke in 1562 and retold in prose in Palace of Pleasure by William Painter in 1567. Shakespeare borrowed heavily from both but expanded the plot by developing a number of supporting characters, particularly Mercutio and Paris. Believed to have been written between 1591 and 1595, the play was first published in a quarto version in 1597. The text of the first quarto version was of poor quality, however, and later editions corrected the text to conform more closely with Shakespeare's original.</span>
</p>
<p style="margin-bottom: 10px;">
    <span style="font-size: 12px;">Shakespeare's use of his poetic dramatic structure (especially effects such as switching between comedy and tragedy to heighten tension, his expansion of minor characters, and his use of sub-plots to embellish the story) has been praised as an early sign of his dramatic skill. The play ascribes different poetic forms to different characters, sometimes changing the form as the character develops. Romeo, for example, grows more adept at the sonnet over the course of the play.</span>
</p>
<p style="margin-bottom: 10px;">
    <span style="font-size: 12px;">Romeo and Juliet has been adapted numerous times for stage, film, musical, and opera venues. During the English Restoration, it was revived and heavily revised by William Davenant. David Garrick's 18th-century version also modified several scenes, removing material then considered indecent, and Georg Benda's Romeo und Julie omitted much of the action and added a happy ending. Performances in the 19th century, including Charlotte Cushman's, restored the original text and focused on greater realism. John Gielgud's 1935 version kept very close to Shakespeare's text and used Elizabethan costumes and staging to enhance the drama. In the 20th and into the 21st century, the play has been adapted in versions as diverse as George Cukor's 1936 film Romeo and Juliet, Franco Zeffirelli's 1968 version Romeo and Juliet, and Baz Luhrmann's 1996 MTV-inspired Romeo + Juliet.</span>
</p>

Script error

react-dom.production.min.js:101 Uncaught TypeError: Cannot read properties of undefined (reading 'height')
    at t.scrollSelectedTokenIntoView (virtualized-content-pane.tsx:1856:58)
    at t.setSelectedExpressionForTts (virtualized-content-pane.tsx:1639:18)
    at t.setCurrentlyReadToken (virtualized-content-pane.tsx:1762:18)
    at t.selectToken (virtualized-content-pane.tsx:1719:14)
    at n.onClick (virtualized-content-pane.tsx:730:19)
    at Object.We (react-dom.production.min.js:52:317)
    at Je (react-dom.production.min.js:52:471)
    at react-dom.production.min.js:53:35
    at _o (react-dom.production.min.js:100:68)
    at Do (react-dom.production.min.js:101:380)

Tested with https://ircdname.azureedge.net/immersivereadersdk/immersive-reader-sdk.1.3.0.js

cadi3s commented 8 months ago

I guess the bug occurs in the Azure Immersive Reader itself, not this Immersive Reader SDK. So feel free to close this issue. Would appreciate if it could be forwarded to the Azure Immersive Reader team though. Will ask around on SO.

cristobal-buenrostro commented 2 months ago

Hi @cadi3s , I tried to repro this issue but was not possible, can you please provide repro steps more in detail?

I tried both text/plain and text/html, and also starting in the phrase you mentioned, and everything is read out loud.

cadi3s commented 2 months ago

Hi @cristobal-buenrostro my code is pretty standard, I think. The weird behavior seems in this particular content (although there is nothing out of the ordinary in the content as well that I can see) or maybe simply the length of the content.

I include immersive-reader-sdk.1.3.0.js After getting configuration parameters, options and a token (all standard stuff), I call ImmersiveReader.launchAsync(token, subdomain, data, options)

The data contains a title (just a string) and two chunks:

image

The string in the first chunk is rather long, html and contains a couple of paragraphs:

<p style="margin-bottom: 10px;"><span style="font-size: 12px;">Romeo and Juliet is a tragedy written by William Shakespeare early in his career about two young star-crossed lovers whose deaths ultimately reconcile their feuding families. It was among Shakespeare's most popular plays during his lifetime and along with Hamlet, is one of his most frequently performed plays. Today, the title characters are regarded as archetypal young lovers.</span></p><p style="margin-bottom: 10px;"><span style="font-size: 12px;">Romeo and Juliet belongs to a tradition of tragic romances stretching back to antiquity. The plot is based on an Italian tale translated into verse as The Tragical History of Romeus and Juliet by Arthur Brooke in 1562 and retold in prose in Palace of Pleasure by William Painter in 1567. Shakespeare borrowed heavily from both but expanded the plot by developing a number of supporting characters, particularly Mercutio and Paris. Believed to have been written between 1591 and 1595, the play was first published in a quarto version in 1597. The text of the first quarto version was of poor quality, however, and later editions corrected the text to conform more closely with Shakespeare's original.</span></p><p style="margin-bottom: 10px;"><span style="font-size: 12px;">Shakespeare's use of his poetic dramatic structure (especially effects such as switching between comedy and tragedy to heighten tension, his expansion of minor characters, and his use of sub-plots to embellish the story) has been praised as an early sign of his dramatic skill. The play ascribes different poetic forms to different characters, sometimes changing the form as the character develops. Romeo, for example, grows more adept at the sonnet over the course of the play.</span></p><p style="margin-bottom: 10px;"><span style="font-size: 12px;">Romeo and Juliet has been adapted numerous times for stage, film, musical, and opera venues. During the English Restoration, it was revived and heavily revised by William Davenant. David Garrick's 18th-century version also modified several scenes, removing material then considered indecent, and Georg Benda's Romeo und Julie omitted much of the action and added a happy ending. Performances in the 19th century, including Charlotte Cushman's, restored the original text and focused on greater realism. John Gielgud's 1935 version kept very close to Shakespeare's text and used Elizabethan costumes and staging to enhance the drama. In the 20th and into the 21st century, the play has been adapted in versions as diverse as George Cukor's 1936 film Romeo and Juliet, Franco Zeffirelli's 1968 version Romeo and Juliet, and Baz Luhrmann's 1996 MTV-inspired Romeo + Juliet.</span></p>

The reader launches fine, and starts to read aloud. The first few paragraphs are read aloud ok. Then, it stops reading aloud after the phrase "over the course of the play." In my page, it occurs 'almost' always. Sometimes if I scroll down to that phrase, and start reading aloud at that sentence, the problem does not occur. If I start reading at the top of the page, it always happen.

When it hangs, there is no script error. I can still select words in the paragraphs above and including that phrase "over the course of the play." But if I click on a word below that paragraph (in a section that was never read aloud), the word is not highlighted, and I see a script error:

image

cristobal-buenrostro commented 2 months ago

can you please try disabling all your browser extensions? what's your current browser? I tried following your repro steps and it keeps working fine for me in Edge.

cadi3s commented 2 months ago

I saw it in Chrome, Edge and Firefox. I will try to set up a simple test page that is publicly accessible.

cristobal-buenrostro commented 1 month ago

@cadi3s please let us know if you could publish a test page to repro the issue

cadi3s commented 1 month ago

@cristobal-buenrostro I created a test page at https://demo.cumlaudelearning.com/test-ir.html Please open it, click on the launch button, then click on the Play button.
Let it read the entire text (it is a bit long, but I could not create a test page with a shorter text).

When I do that, reading stops on its own after ".. over the course of the play". If you then click on a word below that, e.g. on 'Juliet' in the line below, you see the script error. I reproduced it in Chrome, Edge and Firefox.

image

Please let me know if you can or cannot reproduce the issue. At some point I will have to remove that test page.

cristobal-buenrostro commented 1 month ago

@cadi3s I tried in chrome, edge and firefox and all the context was read correctly.

cadi3s commented 1 month ago

@cristobal-buenrostro did you let it run to the indicated line? I can consistently reproduce the bug if I let Immersive Reader read the text, uninterrupted. Also, do not resize the window or click anywhere, just press Play and wait. It usually takes around 1:30 minutes to get to ".. over the course of the play". At that point, reading stops, and the grey overlay with white word highlighting disappears. If you click on the word 'Juliet' below (again without resizing the browser), you should get that script error. We could try to set up a Teams Meeting where I can show what we see.