Added Essentials TextToSpeech#178
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an Avalonia-backed implementation of MAUI Essentials TextToSpeech, integrating desktop (external TTS tools) and browser (Web Speech API) backends into Avalonia.Controls.Maui.Essentials, along with docs, samples, and tests.
Changes:
- Introduces
AvaloniaTextToSpeechwith desktop (espeak-ng/spd-say) and browser (Web Speech API) implementations. - Registers
TextToSpeech.DefaultviaUseAvaloniaEssentials()and updates docs/status. - Adds ControlGallery sample UI and xUnit tests covering validation/cancellation behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Avalonia.Controls.Maui.Essentials.Tests/AvaloniaTextToSpeechTests.cs | Adds unit tests for validation, cancellation behavior, and interface compliance. |
| STATUS-ESSENTIALS.md | Marks TextToSpeech API + supporting types as implemented. |
| src/Avalonia.Controls.Maui.Essentials/wwwroot/js/speechSynthesis-interop.js | Adds JS module wrapping Web Speech API voice listing/speaking/cancel. |
| src/Avalonia.Controls.Maui.Essentials/TextToSpeech/SpeechSynthesisInterop.Browser.cs | Adds JSImport bindings + module import for the JS interop module. |
| src/Avalonia.Controls.Maui.Essentials/TextToSpeech/AvaloniaTextToSpeech.cs | Adds core ITextToSpeech implementation with option validation + serialization lock. |
| src/Avalonia.Controls.Maui.Essentials/TextToSpeech/AvaloniaTextToSpeech.Default.cs | Adds desktop backend using external processes to enumerate locales and speak. |
| src/Avalonia.Controls.Maui.Essentials/TextToSpeech/AvaloniaTextToSpeech.Browser.cs | Adds browser backend using the JS module + voice enumeration. |
| src/Avalonia.Controls.Maui.Essentials/README.md | Documents TextToSpeech support and usage example. |
| src/Avalonia.Controls.Maui.Essentials/MauiEssentialsBuilderExtensions.cs | Registers TextToSpeech.Default to use AvaloniaTextToSpeech. |
| src/Avalonia.Controls.Maui.Essentials/Avalonia.Controls.Maui.Essentials.csproj | Packs wwwroot/** as static web assets for browser interop. |
| samples/ControlGallery/ControlGallery/Pages/TextToSpeechPage.xaml | Adds a sample page UI for speaking text with options/locales. |
| samples/ControlGallery/ControlGallery/Pages/TextToSpeechPage.xaml.cs | Adds sample page logic for locale loading, speaking, and cancellation. |
| samples/ControlGallery/ControlGallery/MainPage.xaml.cs | Adds TextToSpeech sample to navigation/menu. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This is what I get in Safari
This is what I get in Firefox, Edge, and Chrome. I can't get it to run in any browser. Debug or Release mode. For Desktop, I'm not sure of the approach. https://github.com/dotnet/maui/tree/63d534adcce8fc4bea557db56a72216b2fa767b5/src/Essentials/src/TextToSpeech MAUI includes an implementation for all platforms except Linux and WASM. With what's here, if you ran this on any other platform, you get
Since the MAUI ones use the SDK bindings, we can't necessarily use them out of the box (And I would rather not reimplement them wholesale here, too, when they'll basically be the same thing, but with PInvokes). For the Linux stuff, I'm not sure how I feel about wrapping existing programs through This is a situation where I think we should wrap a cross-platform TTS library (at least for Desktop use) and map it to the essentials API, like how Maps would have worked. That would make it easier to bundle a dependency (or direct devs to what they need to bundle) and not require installed apps to exist on the users machine. |
Originally did tests on Ubuntu (24.04.4 LTS). Fixed an issue with the incorrect browser voice deserialization. Tested on Chrome, Edge from macOS and works.
Should get correct voice and do the text to speech.
|
|
@jsuarezruiz Can you try clearing all your bin/obj's and try testing again in WASM? Testing it on my Arch install, on Firefox, Edge, and Chrome, I got
My guess is it may have worked for you because it either happened to exist in the wwwroot folder in ControlGallery when you were testing it, or whatever ASP.NET saw when it was setting up the file resolves happened to get it right, but I've tried this now on several computers and OSs, and I can't get it working. |







Add an Avalonia implementation of MAUI Essentials TextToSpeech.
Changes:
ITextToSpeechsupport inAvalonia.Controls.Maui.EssentialsTextToSpeech.DefaultthroughUseAvaloniaEssentials()espeak-ngwithspd-sayfallback