Coder Social home page Coder Social logo

microsoft / immersive-reader-sdk Goto Github PK

View Code? Open in Web Editor NEW
89.0 11.0 52.0 10.12 MB

SDK for using the Immersive Reader through Cognitive Services

License: MIT License

JavaScript 9.06% TypeScript 13.35% C# 10.65% HTML 36.61% CSS 1.98% Python 0.34% Java 9.58% Ruby 0.31% Swift 7.23% Kotlin 6.54% Pug 2.77% Objective-C 0.12% Handlebars 1.46%
immersive-reader cognitive-services

immersive-reader-sdk's Introduction

Azure Applied AI Immersive Reader - Immersive Reader SDK

The Immersive Reader SDK is a set of libraries that allow you to easily and quickly integrate the Immersive Reader into your application.

Usage

Contributing

We welcome contributions to this project.

Please submit pull requests to the dev branch.

Reporting Security Issues

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License.

immersive-reader-sdk's People

Contributors

alexisglez avatar ashwanibansal1 avatar cristobal-buenrostro avatar dependabot[bot] avatar dilipptdr avatar dmcallis avatar dpaulino avatar dylankil avatar filipwennerdahl avatar guillaumesimonnet avatar meganroach avatar metanmsft avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar mocha1995 avatar msftgits avatar nickblow avatar parkergirard avatar robinwassen avatar rwallerms avatar sahirboghani avatar sandeepcongh avatar suchk avatar tessawiedmann avatar tylerthedeveloper avatar v-rr avatar yanirshahak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

immersive-reader-sdk's Issues

Play/Pause button should not require extra space for apps that suppress the app bar footer in Andorid and iOS Native Apps

Reader Controls Button Excess Space in Native App

There's a known issue on iOS where the app bar footer occludes content of web applications and is not factored into the height of the viewport. Apple has resolved this 'As designed'. As a workaround, the Immersive Reader applies extra padding to the bottom of the play/pause button. Native apps do not require this space.

There's an SDK option 'useWebview' tha may be used to set layout porperties of the web app. The Immersive Reader web app requires a few changes to ensure this boolean removes the extra space.

There's also extra space in the menu options panel that should be removed in native apps:

Extra Space Panel

Testing

Test issue, please ignore.

readaloudoptions not working

Configuring readAloudOptions on launch does not have any effect.

Have tried variations of this (e.g. autoplay -> autoPlay, male -> Male without success. The reader opens and requires manual starting and configuration.

Browsers tested Chrome, Edge.

This is the JS configuration:

const options = {
        "readAloudOptions": {
            "autoplay": true,
            "voice": 'male'
        },
        "onExit": exitCallback,
        "uiZIndex": 1000000
    };

Line breaks is stripped from the content for chrome webview

Line breaks from example "p" and "br" tags is stripped when using a webview on chrome apps.
Using the same code for both our chrome and electron app (except for using webview on chrome) results in different results.

Correct format using an iframe:
Screenshot 2019-09-06 at 15 04 57

Incorrect format using a chrome webview:
Screenshot 2019-09-06 at 15 07 07

Quality drop on every new sentence

Hi,

I integrated the immersive reader recently in the UWP app and my manager who lives in Portugal tried it. Another colleague in Portugal has the same issue. I cannot repro on my side. As a reference, the Immersive Reader is a black box and it is a website hosted by Microsoft essentially.

Problem: When the reader arrives at the end of the sentence and starts a new sentence, the quality drops. You can see the word “Other” and “These” in the video.
https://user-images.githubusercontent.com/1608424/115884669-282d5b00-a41d-11eb-9448-9ef27f204dc8.mp4. It does that for every sentence. I even created the Azure resource in Europe along with East US, but no change.

Publish immersive-reader-sdk on npm

Any chance that you can publish the built SDK on npm when releasing new versions? It would help for dependency management of the SDK when bundling it into an Electron app.

iframe src domain not set correctly

When not using a custom domain, the default domain is not set.
Currently options.customDomain is checked against null, it should instead be a truthy check since customDomain is undefined if not set.

Sudden TokenExpired message on using SDK

I have a project that was using the SDK with Azure AD Application and IR resource. It was working for several months until recently where now every request opens the frame for IR but now returns:

image

I changed some of the settings for subdomain, Secrets etc as a test and when changed the IR times out completely which leaves me to believe the settings I have are correct. The code to get the token is successful and using console.log I can see both it and the subdomain are ok before ImmersiveReader.LaunchAsync fires.

In order to check it wasn't me, my machine, my code etc I grabbed another dev example online: https://github.com/kasuken/ImmersiveReaderCore . I tested with the settings as is first and IR opened ok. I changed the settings to my own TenantID etc and the error returned. I have raised a support ticket with Azure as it was working before and feels like an account issue but if anyone can help I would appreciate it as its used in an application for specialist students.

Immersive reader does not reset state on errors

Steps to reproduce:

  1. Open up the simple sample for Immersive Reader while online
  2. Go offline (either for real or toggle "Offline" in dev tools)
  3. Click on a button to open the Immersive Reader

Expected outcome: Immersive reader should not open up (or close again when the page fails to load)

Actual outcome: Immersive reader opens up full screen but fail to load, user ends up with a white page.

I think that this could be solved by calling the reset() function instead of resetTimeout() when ImmersiveReader-TokenExpired, ImmersiveReader-Throttled or ErrorCode.Timeout occurs in launcAsync.

Another note is that this problem becomes a bit harder to work around as a developer due to lack of classes and/or id on the iframeContainer element since it's error prone to programmatically access it today.

Python documentation

Can you please add python documentation for Immersive Reader, specifically a Flask example would be very helpful.

why there is no immersive reader in linux? at least make it SaaS

hey there i really love immersive reader when i was using Windows. it is amazing. it just perfect. but now i am using Linux due to system performance issue. i have Azure Account and why don't just charge me when i want use Immersive Reader in linux using AAD auth. i am really dissapointed by this decision. this technology should accessible to anyone, even for people "tech savvy" because not all people have time to build their own Immersive Reader. i try to build Chromium Extentions using microsoft account log in. i wish i can find a way to make this tech more accessible to many people. please help me.

Browser default language - translation function does not work

When the browser default language is Chinese, the translation function cannot translate English to Chinese. Cases that cannot be translated:
(1) When the browser default language is Chinese, the text content is "How are you", and then choose to translate into Chinese.
(2) When the browser default language is English, the text content is "你好嗎", and then choose to translate into English.

SDK version: 1.1.0
Browser version: Chrome 86.0.4240.198

How to use immersive reader in uwp app?

I see that immersive reader is essentially a JavaScript based control. I'm trying to figure out how to add this into a c# xaml uwp app. Any ideas? I'd be happy to spearhead this, but I'd like to get some pointers since I'm not sure where to start

Provide types for `onPreferencesChanged` string

In the handler for onPreferencesChanged, it would be great to be able to parse the string using known types provided by the SDK. Today, the VSCode for Education Extension uses manually created types based on the preferences string we received at the time. If they change at any point, the current method of fixing it would be to once again manually take a look at the string rather than updating a package to obtain the new types.

At minimum, the documentation, could define what's expected in the onPreferencesChanged string.

Some of the types returned in the prefs string were documented, but not all. Below is an example.

export type TranslationLanguageData = {
    tlc: string;
    slc: string;
};

export type TranslationLanguage = {
    key: string;
    text: string;
    data: TranslationLanguageData;
};

See https://github.com/microsoft/vscode-edu-extension/pull/1532/files for context. If you need access to the repository, please comment or message offline.

Can't reopen Immersive Reader without refreshing if user exits early

We just added Immersive Reader to the MakeCode Arcade tutorials, and we've noticed that if an error occurs between launching the Immersive Reader and displaying the content, and the user presses the back button, they won't be able to reopen it until they refresh (with an 'Immersive Reader is already launching' error).

For example, if a user loses internet connection while launching, they won't be able to launch again.

I did a local build of the SDK where I added isLoading = false to the exit function --

, and it seems to fix it for our case! But let me know if we're calling the SDK incorrectly and this isn't a bug 😊 I am also happy to open a PR to contribute!

Safari webview on iOS is not populated correctly

When starting Immersive Reader through the javascript sdk on a iOS Safari webview it displays a blank page.
Looking inside the iframe added to the body, the div containing the react app is not populated:

Screenshot 2019-09-06 at 12 14 16

When testing on the electron version of our app using the same code, the div is correctly populated:
Screenshot 2019-09-06 at 12 23 39

Add option to turn off Grammar and Translation buttons

In a Learning Management System, some courses are about learning a different language.
In such cases reading an assignment in the original language with ImmersiveReader can be very helpful, but a teacher would not want their students to see the correct translation.

onPreferencesChanged does not support shouldTranslateDocument

Hi, if a user selects 'translate document', I want to remember that setting and lauch each new instance of ImmersiveReader with autoEnableDocumentTranslation = true until the user switches this off again.

Unfortunately, the onPreferencesChanged callback is not called when changing the 'translate document' button.
And if the onPreferencesChanged callback is called for something else, the translationState does not contain a flag for e.g. shouldTranslateDocument.

Is this a bug, and if so, is a fix on the roadmap?

Tested with immersive-reader-sdk.js version 1.1.0.

Break/pause between line

Hello,
In "old" documentation, i think i read i'ts possible to add some html mark to break/pause the reader ? Actually, i don't find way to stop reader after each line.

Kind regards,

Change Voice Engine || Open Source Immersive Reaader?

Hi there,
Love the project. I would like to request to enable OpenAI's TTS for the voice instead of MSFT's model. Ideally, the voice method would take an openAI key parameter and then allow the developer to use that model and the voice options within.

I'm not sure how much support Immersive Reader is getting right now but if you open-source it then it may take off as engineers are working with text AI more than ever before.

Cheers,
Jeremiah

Unable to create Immersive Reader with AAD configuration according to PowerShell script

This resource https://docs.microsoft.com/en-us/azure/applied-ai-services/immersive-reader/how-to-create-immersive-reader documents a PowerShell script that would create the resources and configure them as need be. However, I am encountering troubles trying to execute the script, such as the following:

SecretExpiration '2022-12-31'                        
Exception: 
Line |
  17 |          throw "Error: AADAppIdentifierUri must be a valid URI"
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Error: AADAppIdentifierUri must be a valid URI

image

Is there any advice or fix for this?

Doesn't work correctly

I can't see the immersive reader. Only this message."The appropriate information could not be obtained to display the text correctly."

Chrome app compatibility mode loads blank iframe

We have immersive-reader into our app which is running as a Chrome app, as mentioned in #8 we are launching with the option useWebview: true. But end up with a blank iframe inside the WebView (from a user perspective the app becomes white).

Code used to launch Immersive Reader:

const content = {
    title: self.question.title,
    chunks: [ {
        content: helperElement.innerText,
    } ],
};

const options = {
    useWebview: true,
}

ImmersiveReader.launchAsync(accessToken, content, options);

Result:
image

In our Electron app immersive reader works with useWebview: false, if useWebview: true is set in the Electron app it produces the exact same result.

I know that useWebview option is designed for Chrome though.

Read aloud stops at certain html content

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:

  • read aloud proceeds until the last paragraph, and there it stops
  • if I click on text in that last paragraph (starting with 'Romeo and Juliet has been adapted') I see a script error

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

Overlay doesnt close on route change

Hi,

we use Immersive Reader on a few places in our project with React and React router. Theres a confusing behaviour of the Immersive Reader overlay. If the user goes back a page etc with the browser controls the Immersive Reader overlay is still showing. Can I fix this? Is this expected behaviour on your end?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.