Table of Contents

Class Backend

Namespace
Refractor
Assembly
Refractor.dll

A speech, braille or screen reader output. Not thread safe: use one instance from one thread at a time. Check GetFeatures() before relying on an operation, since an unsupported one throws PrismException with NotImplemented.

public sealed class Backend : IDisposable
Inheritance
Backend
Implements
Inherited Members

Properties

BitDepth

The engine's native depth. SpeakToMemory(string, AudioCallback) always delivers 32 bit floats.

public int BitDepth { get; }

Property Value

int

Channels

How many channels SpeakToMemory(string, AudioCallback) delivers.

public int Channels { get; }

Property Value

int

IsSpeaking

Whether speech is in progress.

public bool IsSpeaking { get; }

Property Value

bool

Name

The backend's name, such as "NVDA" or "SAPI".

public string Name { get; }

Property Value

string

Pitch

From 0 to 1. Screen readers do not support it.

public float Pitch { get; set; }

Property Value

float

Rate

From 0 to 1, where 0.5 is always the backend's default.

public float Rate { get; set; }

Property Value

float

SampleRate

The sample rate SpeakToMemory(string, AudioCallback) delivers, in hertz.

public int SampleRate { get; }

Property Value

int

VoiceCount

How many voices the backend has.

public int VoiceCount { get; }

Property Value

int

VoiceIndex

The index of the current voice.

public int VoiceIndex { get; set; }

Property Value

int

Volume

From 0 to 1.

public float Volume { get; set; }

Property Value

float

Methods

Braille(string)

Shows text on the user's braille display.

public void Braille(string text)

Parameters

text string

Dispose()

Frees this handle. Speech in progress may or may not stop, so call Stop() first to be sure.

public void Dispose()

GetFeatures()

May probe the system to fill in IsSupportedAtRuntime, so cache the result.

public BackendFeatures GetFeatures()

Returns

BackendFeatures

GetVoiceLanguage(int)

The voice's language, such as "en-US", or null when the backend reports none for it.

public string? GetVoiceLanguage(int index)

Parameters

index int

Returns

string

GetVoiceName(int)

The name of the voice at index.

public string GetVoiceName(int index)

Parameters

index int

Returns

string

GetVoices()

Every voice, with its language when the backend reports one.

public IReadOnlyList<Voice> GetVoices()

Returns

IReadOnlyList<Voice>

Initialize()

Returns false when it was already initialized, which is not an error.

public bool Initialize()

Returns

bool

Output(string, bool)

Speech and braille together. Success can mean only one of them worked.

public void Output(string text, bool interrupt = false)

Parameters

text string
interrupt bool

Pause()

Pauses speech where it is. Resume() carries on from there.

public void Pause()

RefreshVoices()

Picks up newly installed voices. Indexes may move, so store voice names, not indexes.

public void RefreshVoices()

Resume()

Carries on with speech paused by Pause().

public void Resume()

Speak(string, bool)

Speaks, and may return before the speech ends. Without interrupting, most backends queue.

public void Speak(string text, bool interrupt = false)

Parameters

text string
interrupt bool

SpeakToMemory(string, AudioCallback)

Synthesizes to callback instead of the speakers, and returns only when all audio is delivered. The callback may run on another thread and must not use this backend. An exception it throws is rethrown here once synthesis ends.

public void SpeakToMemory(string text, AudioCallback callback)

Parameters

text string
callback AudioCallback

Stop()

Stops this backend's speech and drops its queue. A screen reader's own speech carries on.

public void Stop()

Supports(BackendFeatures)

Whether the backend has every one of features.

public bool Supports(BackendFeatures features)

Parameters

features BackendFeatures

Returns

bool