Class TextToSpeech
Accessibility API for reading text aloud with a speech synthesis backend.
Inherited Members
Namespace: Ritchie.Toolbox.Accessibility
Assembly: Ritchie.Toolbox.dll
Syntax
public static class TextToSpeech
Properties
IsAvailable
Gets a value indicating whether speech synthesis is available.
Declaration
public static bool IsAvailable { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
SetSpeechHandler(ISpeechHandler?)
Switch the current speech backend.
Declaration
public static void SetSpeechHandler(ISpeechHandler? newSpeechHandler)
Parameters
Type | Name | Description |
---|---|---|
ISpeechHandler | newSpeechHandler | The new backend to use. If null is provided, speech synthesis support will be disabled. |
SpeakAsync(string)
Speak the given text with the current speech backend.
Declaration
public static Task SpeakAsync(string textToSpeak)
Parameters
Type | Name | Description |
---|---|---|
string | textToSpeak | The text to speak |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | An awaitable task that completes when speech finishes. |
TrySpeakAsync(string)
Tries to read the specified text aloud with the current speech backend.
Declaration
public static Task<bool> TrySpeakAsync(string textToSpeak)
Parameters
Type | Name | Description |
---|---|---|
string | textToSpeak | The text to speak. |
Returns
Type | Description |
---|---|
Task<bool> | A task that waits for speech to finish, and returns true if speech was successful. |