Blazor.SpeechSynthesis.WebAssembly 2.0.11

.NET 6.0
dotnet add package Blazor.SpeechSynthesis.WebAssembly --version 2.0.11
NuGet\Install-Package Blazor.SpeechSynthesis.WebAssembly -Version 2.0.11
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blazor.SpeechSynthesis.WebAssembly" Version="2.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Blazor.SpeechSynthesis.WebAssembly --version 2.0.11
#r "nuget: Blazor.SpeechSynthesis.WebAssembly, 2.0.11"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Blazor.SpeechSynthesis.WebAssembly as a Cake Addin
#addin nuget:?package=Blazor.SpeechSynthesis.WebAssembly&version=2.0.11

// Install Blazor.SpeechSynthesis.WebAssembly as a Cake Tool
#tool nuget:?package=Blazor.SpeechSynthesis.WebAssembly&version=2.0.11

Blazorators: The Source Generated speechSynthesis JavaScript Interop library for Blazor WebAssembly

The Blazor.SpeechSynthesis.WebAssembly package consumes the Blazor.SourceGenerators package. It exposes a source generated ISpeechSynthesis interface specific to Blazor WebAssembly and the speechSynthesis Web API.

Get started

After the NuGet package is added as a reference, call the AddSpeechSynthesisServices method to register the ISpeechSynthesisService type.

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

    sp => new HttpClient
        BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)


await builder.Build().RunAsync();

Anywhere needed within your Razor component, or Blazor client code — either @inject or [Inject] the ISpeechSynthesisService type. The interface takes the following shape:

using Blazor.Serialization.Extensions;
using System.Text.Json;

#nullable enable

namespace Microsoft.JSInterop;
/// <summary>
/// Source generated interface definition of the <c>SpeechSynthesis</c> type.
/// </summary>
public partial interface ISpeechSynthesisService
    /// <summary>
    /// Source generated implementation of <c>window.speechSynthesis.cancel</c>.
    /// <a href=""></a>
    /// </summary>
    void Cancel();
    /// <summary>
    /// Source generated implementation of <c>window.speechSynthesis.getVoices</c>.
    /// <a href=""></a>
    /// </summary>
    SpeechSynthesisVoice[] GetVoices();
    /// <summary>
    /// Source generated implementation of <c>window.speechSynthesis.pause</c>.
    /// <a href=""></a>
    /// </summary>
    void Pause();
    /// <summary>
    /// Source generated implementation of <c>window.speechSynthesis.resume</c>.
    /// <a href=""></a>
    /// </summary>
    void Resume();
    /// <summary>
    /// Source generated implementation of <c>window.speechSynthesis.paused</c>.
    /// <a href=""></a>
    /// </summary>
    bool Paused { get; }

    /// <summary>
    /// Source generated implementation of <c>window.speechSynthesis.pending</c>.
    /// <a href=""></a>
    /// </summary>
    bool Pending { get; }

    /// <summary>
    /// Source generated implementation of <c>window.speechSynthesis.speaking</c>.
    /// <a href=""></a>
    /// </summary>
    bool Speaking { get; }

Add JavaScript dependency

In the _Host.cshtml file, add the following:

<script src="_content/Blazor.SpeechSynthesis.WebAssembly/blazorators.speechSynthesis.g.js"></script>
Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.11 136 10/10/2022
2.0.10 216 5/19/2022
2.0.9 183 4/18/2022
2.0.8 181 4/14/2022
2.0.7 168 4/14/2022
2.0.6 185 4/7/2022
2.0.5 174 4/5/2022
2.0.2 175 4/4/2022
2.0.1 168 4/4/2022
1.5.0 169 3/29/2022