Screen Reader Abstraction Library
SRAL is a cross-platform library for output text using speech engines.
SRAL is supported on Windows, MacOS and Linux platforms.
This enumeration defines the available speech engines supported by the SRAL library. The values are:
ENGINE_NONE = 0
: No engine selected.ENGINE_NVDA = 2
: NVDA screen reader.ENGINE_SAPI = 4
: Microsoft SAPI5 speech engine.ENGINE_JAWS = 8
: Jaws screen reader.ENGINE_SPEECH_DISPATCHER = 16
: Speech Dispatcher engine.ENGINE_UIA = 32
: Microsoft UI Automation provider.ENGINE_AV_SPEECH = 64
: AVSpeech engine.
This enumeration defines the features supported by the various speech engines. The values are:
SUPPORTS_SPEECH = 128
: The engine supports speech output.SUPPORTS_BRAILLE = 256
: The engine supports Braille output.SUPPORTS_SPEECH_RATE = 512
: The engine supports setting the speech rate.SUPPORTS_SPEECH_VOLUME = 1024
: The engine supports setting the speech volume.SUPPORTS_SELECT_VOICE = 2048
: The engine supports selecting a specific voice.
- Description: Speaks the given text.
- Parameters:
text
: A pointer to the text string to be spoken.interrupt
: A flag indicating whether to interrupt the current speech.
- Return Value:
true
if speaking was successful,false
otherwise.
- Description: Outputs the given text to a Braille display.
- Parameters:
text
: A pointer to the text string to be output in Braille.
- Return Value:
true
if Braille output was successful,false
otherwise.
- Description: Outputs the given text using all currently supported speech engine methods.
- Parameters:
text
: A pointer to the text string to be output.interrupt
: A flag indicating whether to interrupt the current speech.
- Return Value:
true
if output was successful,false
otherwise.
- Description: Stops speech if it is active.
- Return Value:
true
if speech was stopped successfully,false
otherwise.
- Description: Gets the current speech engine in use.
- Return Value: The identifier of the current speech engine defined by the
SRAL_Engines
enumeration.
- Description: Gets the features supported by the specified engine.
- Parameters:
engine
: The identifier of the engine to query. Defaults to 0 (current engine).
- Return Value: An integer representing the features supported by the engine defined by the
SRAL_SupportedFeatures
enumeration.
- Description: Initializes the library and optionally excludes certain engines.
- Parameters:
engines_exclude
: A bitmask specifying engines to exclude from initialization. Defaults to 0 (include all).
- Return Value:
true
if initialization was successful,false
otherwise.
- Description: Uninitializes the library, freeing resources.
- Description: Sets the speech volume level, if the current speech engine supports this.
- Parameters:
value
: The desired volume level.
- Return Value:
true
if the volume was set successfully,false
otherwise.
- Description: Gets the current speech volume level of the current speech engine.
- Return Value: The current volume level.
- Description: Sets the speech rate, if the current engine supports this.
- Parameters:
value
: The desired speech rate.
- Return Value:
true
if the speech rate was set successfully,false
otherwise.
- Description: Gets the current speech rate of the current speech engine.
- Return Value: The current speech rate.
- Description: Gets the count of available voices supported by the current speech engine.
- Return Value: The number of available voices.
- Description: Gets the name of a voice by its index, if the current speech engine supports this.
- Parameters:
index
: The index of a voice to get.
- Return Value: A pointer to the name of the voice.
- Description: Sets the currently selected voice by index, if the current speech engine supports this.
- Parameters:
index
: The index of a voice to set.
- Return Value:
true
if the voice was set successfully,false
otherwise.
The library also provides extended functions to perform operations with specific speech engines. These functions follow the same naming convention as the regular functions, but with the addition of the Ex
suffix. For example, SRAL_SpeakEx
, SRAL_BrailleEx
, SRAL_OutputEx
, etc.
- Description: Checks if the library has been initialized.
- Return Value:
true
if the library is initialized,false
otherwise.
- Description: Delayes the next speech or output operation by a given time.
C
#include <stdio.h>
#include <SRAL.h>
int main(void) {
// Initialize the SRAL library
if (!SRAL_Initialize(0)) {
printf("Failed to initialize SRAL library.\n");
return 1;
}
// Speak some text
if (!SRAL_Speak("Hello, world!", false)) {
printf("Failed to speak text.\n");
}
// Output text to a Braille display
if (!SRAL_Braille("This is Braille output.")) {
printf("Failed to output to Braille display.\n");
}
// Uninitialize the SRAL library
SRAL_Uninitialize();
return 0;
}
For NVDA screen reader, you need to download the Controller Client for this.