text-to-socket-engine

TextToSocketEngine is an implementation of the Windows Speech API Text-To-Speech engine interface that simply redirects all the text it receives to a configured TCP socket, instead of converting the text to speech (as regular TTS engines do).

Usage no npm install needed!

<script type="module">
  import textToSocketEngine from 'https://cdn.skypack.dev/text-to-socket-engine';
</script>

README

TextToSocketEngine

npm

TextToSocketEngine is an implementation of the Windows SAPI TTS engine interface (ISpTTSEngine) that simply redirects all the text it receives to a configured TCP socket, instead of converting the text to speech (as regular TTS engines do).

It is based on the TTS engine example provided by Microsoft.

It is especially useful to test software that can read text through the Windows Speech API. Some screen readers (such as JAWS) can be configured to use it, so the "text to socket" engine provided in this directory can be used in automatic tests to check that some software or website works as expected with those screen readers.

Especially, it was done with the purpose of being used with assistive-webdriver to automate end-to-end tests with a screen reader.

Installation from npm

text-to-socket-engine can be installed from npm:

npm install -g text-to-socket-engine

Once installed it has to be registered with the following command (from a command prompt with administrator privileges):

text-to-socket-engine-register

This first registers the engine and then creates a default voice that uses it. The default voice has the textToSocketVoice id, is displayed in configuration dialogs as Text To Socket 127.0.0.1:4449 and is configured to redirect all text to 127.0.0.1 on TCP port 4449.

It is possible to create (and remove) different voices with different settings (different hosts and TCP ports) that all use the same "text to socket" engine, as shown in the following sample commands:

text-to-socket-engine-add-voice voiceToPort4450 "My new voice" 127.0.0.1 4450

text-to-socket-engine-remove-voice voiceToPort4450

To remove the default voice and unregister the engine, use the following command:

text-to-socket-engine-unregister

How to build from the source repository

The build requires Microsoft Visual C++ command line compiler and tools (cl, midl, rc and cvtres).

Execute the build.cmd script from a command prompt with the correct build variables configured. The TextToSocketEngine.dll file will be created.

How to install from the source repository

Execute the register.cmd script from a command prompt with administrator privileges. This first registers the engine and then creates a voice that uses it. The voice has the textToSocketVoice id, is displayed in configuration dialogs as Text To Socket 127.0.0.1:4449 and is configured to redirect all text to 127.0.0.1 on TCP port 4449. To change the settings, just edit the script before running it. It is possible to register different voices with different settings (different hosts and TCP ports) that all use the same "text to socket" engine.

How to uninstall from the source repository

Execute the unregister.cmd script from a command prompt with administrator privileges. It first removes the voice with the textToSocketVoice id then unregisters the engine.