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
Channels
How many channels SpeakToMemory(string, AudioCallback) delivers.
public int Channels { get; }
Property Value
IsSpeaking
Whether speech is in progress.
public bool IsSpeaking { get; }
Property Value
Name
The backend's name, such as "NVDA" or "SAPI".
public string Name { get; }
Property Value
Pitch
From 0 to 1. Screen readers do not support it.
public float Pitch { get; set; }
Property Value
Rate
From 0 to 1, where 0.5 is always the backend's default.
public float Rate { get; set; }
Property Value
SampleRate
The sample rate SpeakToMemory(string, AudioCallback) delivers, in hertz.
public int SampleRate { get; }
Property Value
VoiceCount
How many voices the backend has.
public int VoiceCount { get; }
Property Value
VoiceIndex
The index of the current voice.
public int VoiceIndex { get; set; }
Property Value
Volume
From 0 to 1.
public float Volume { get; set; }
Property Value
Methods
Braille(string)
Shows text on the user's braille display.
public void Braille(string text)
Parameters
textstring
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
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
indexint
Returns
GetVoiceName(int)
The name of the voice at index.
public string GetVoiceName(int index)
Parameters
indexint
Returns
GetVoices()
Every voice, with its language when the backend reports one.
public IReadOnlyList<Voice> GetVoices()
Returns
Initialize()
Returns false when it was already initialized, which is not an error.
public bool Initialize()
Returns
Output(string, bool)
Speech and braille together. Success can mean only one of them worked.
public void Output(string text, bool interrupt = false)
Parameters
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
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
textstringcallbackAudioCallback
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
featuresBackendFeatures