Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When Blazor Is Initialized, and you want to let the user know, "Speak" not working #11

Open
dlevitan opened this issue Jul 1, 2022 · 6 comments

Comments

@dlevitan
Copy link

dlevitan commented Jul 1, 2022

What I am trying to do is to alert the user when the Blazor Application is running in their browser, and this is not working. Stepping through the code, it is executing the code, but not working until you come back to the page.

The following are the steps to reproduce:

After adding a new Blazor Wasm application, installing this library, and then updating the "Index.razor" page to:

@using Toolbelt.Blazor.SpeechSynthesis @{/* Add these two lines. */}
@inject SpeechSynthesis SpeechSynthesis
@page "/"

<PageTitle>Index</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

<SurveyPrompt Title="How is Blazor working for you?" />

@code {

    string Text1 = "Hello From the Blazor application's Home page";
    string Text2 = "Welcome back to the Blazor application's Home page";

    protected override void OnAfterRender(bool firstRender)
    {
        if (firstRender)
        {
            this.SpeechSynthesis.Speak(this.Text1); // <-- Speak!
            this.SpeechSynthesis.Speak(this.Text1); // <-- Speak!
            this.SpeechSynthesis.Speak(this.Text1); // <-- Speak!
        }
        else
        {
            this.SpeechSynthesis.Speak(this.Text2); // <-- Speak!
        }
    }
}

You can only here the message when you come back to the page. In addition, "firstRender" seems to be true when going back to the page. Likewise if you refresh the page, you get the same behavior. So, this may be a Blazor issue or both.

@jsakamoto
Copy link
Owner

@dlevitan Thank you for letting me know!

The architecture of this library causes this problem. I fixed this problem today, and I published it as ver.10.0.0.

Could you try it out?

(By the way, this version is a major update release, and it includes some breaking changes. For example, the synchronous version "Speak" method was deprecated. You can continue using the synchronous version, but the asynchronous version "SpeakAsync" is recommended.)

Again, thank you for your contribution! 👍

@dlevitan
Copy link
Author

dlevitan commented Oct 11, 2022 via email

@jsakamoto
Copy link
Owner

@dlevitan
Sorry too late! I apologize that I overlooked the notification of your reply. 🙇‍♂️

By the way, I could not understand well for your question. Could you explain your question again easier or more specifically? (For example, what is the "Fusion"? I could not understand that word.)

@dlevitan
Copy link
Author

The root of what Fusion is, has to do with making our applications being usable by people who are Visually Impaired. Fusion is by Scientific Freedom and provides both a visual tool [Zoom Text] for a variety of ways to aid the visually impaired as well as a vocal tool [Jaws] that the blind rely on. At this time Blazor does not provide any out of the box tools that could provide some multimedia to a Blazor app. I had hoped that their would be a way to create components in Unity or some other tool and use it within a Blazor app. I believe that an audible sound, for when the application opens and for user feedback would improve the user interface. My opinion is that with an audible click, I know that a button or link has been clicked.

@jsakamoto
Copy link
Owner

@dlevitan

I understood what you mentioned about this: https://www.freedomscientific.com/

My opinion is that with an audible click, I know that a button or link has been clicked.

I see, and I strongly agree with your idea.

But unfortunately, this library is just a wrapper for a web browser's API. The "Text to speech" ability is provided by web browsers, not by this library.

For more detail, please see also: https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API#web_speech_api_interfaces

The "Web Speech API" of web browsers is provided as a JavaScript interface, and it can't be invoked from Blazor C# code directly. This library just provides the bridge from Blazor C# code to the Web Speech API JavaScript interface to make it possible.

And, to the best of my knowledge, there is no way to add custom voices to the Web Speech API of web browsers. I assume the list of voices on the Web Speech API is hardcoded on web browser implementation. Therefore, you would not be able to make the Web Speech API on web browsers use any vocalizers to speak, I guess. To verify what I said, I recommend inquiring to Freedom Scientific.

@jsakamoto
Copy link
Owner

@dlevitan

I found an interesting discussion on the stackoverflow.com.

"HOW TO ADD MORE VOICE FROM MICROSOFT EDGE TO CHROME AND FIREFOX ( only on windows 10 fall creator update or later)"
https://stackoverflow.com/posts/47485786/revisions

Is that useful for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants