A cross-platform C# library designed for seamless integration with the active screen reader on Windows, macOS, and Linux systems. It provides a unified interface for developers to incorporate screen reader functionality into their applications, making it easier to create inclusive and accessible software experiences. This library only works 64-bit environment and it uses Tolk for windows, libspeechdwrapper for linux and libspeak for MacOSX.
As the library is built .NET Standard 2.0, it is compatible with .NET 2.0+, .NET Core 2.0+ and .NET Framework 4.6.1+. More info.
The library is available on nuget and you can use the following command to add it to your project:
dotnet add package TOWK.Utility.CrossSpeak --version 1.0.0
Download the latest version from releases and extract the contents to your project's root.
Add the reference to CrossSpeak.dll
in your project's file as follows:
<ItemGroup>
<Reference Include="./CrossSpeak.dll" />
</ItemGroup>
You would also need to copy the screen reader libraries to the output directory, here's how you can set it up to always copy them on build in your project's file:
<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
<Copy SourceFiles="lib\screen-reader-libs\linux\libspeechdwrapper.so" DestinationFolder="$(OutDir)lib\screen-reader-libs\linux" />
<Copy SourceFiles="lib\screen-reader-libs\windows\nvdaControllerClient64.dll" DestinationFolder="$(OutDir)lib\screen-reader-libs\windows" />
<Copy SourceFiles="lib\screen-reader-libs\windows\SAAPI64.dll" DestinationFolder="$(OutDir)lib\screen-reader-libs\windows" />
<Copy SourceFiles="lib\screen-reader-libs\windows\Tolk.dll" DestinationFolder="$(OutDir)lib\screen-reader-libs\windows" />
<Copy SourceFiles="lib\screen-reader-libs\macos\libspeak.dylib" DestinationFolder="$(OutDir)lib\screen-reader-libs\macos" />
</Target>
Using CrossSpeak is pretty straightforward. Initialize the library and then you can easily interact interact with the active screen reader using the provided API. Check out IScreenReader.cs to get an understanding about the different API method calls.
Here's a quick example:
using CrossSpeak;
CrossSpeakManager.Instance.Initialize();
CrossSpeakManager.Instance.Speak("Hello there!");
CrossSpeakManager.Instance.Close();
Make sure to always call the Close()
method before your application closes.
- Improve linux support by updating
libspeechdwrapper
, maybe use C/C++ for the wrapper library.
- The
IsSpeaking()
method always returnsfalse
for windows. I think this is something that needs to be fixed inTolk
itself.