You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6,7 +6,7 @@ SRAL is a cross-platform library for output text using speech engines.
6
6
## Platforms
7
7
SRAL is supported on Windows, MacOS and Linux platforms.
8
8
9
-
9
+
## Header
10
10
11
11
## Enumerations
12
12
@@ -142,37 +142,155 @@ The library also provides extended functions to perform operations with specific
142
142
### `SRAL_UnregisterKeyboardHooks(void)`
143
143
-**Description**: Uninstall speech interruption and pause keyboard hooks.
144
144
145
+
## Compilation
146
+
SRAL can build using CMake into two libraries, static and dynamic.
147
+
Run these commands
148
+
```
149
+
cmake . -B build
150
+
cmake --build build --config Release
151
+
```
152
+
153
+
You will also have an executable test to test the SRAL.
154
+
155
+
156
+
# Warning
157
+
To build on Linux you need to install libspeechd-dev and libx11-dev
158
+
159
+
160
+
## Usage
161
+
162
+
To use the SRAL API in a C/C++ project, you need a statically linked or dynamically imported SRAL library, as well as a SRAL.h file with function declarations.
163
+
If you use SRAL as a static library for Windows, you need to define SRAL_STATIC in the SRAL.h before the include
164
+
```
165
+
#define SRAL_STATIC
166
+
#include <SRAL.h>
167
+
```
168
+
169
+
## Bindings
170
+
SRAL also has Bindings, which is updated with new wrappers for programming languages.
if (!SRAL_Initialize(ENGINE_UIA)) { // So Microsoft UIAutomation provider can't speak in the terminal or none current process windows
198
+
printf("Failed to initialize SRAL library.\n");
199
+
return 1;
200
+
}
201
+
SRAL_RegisterKeyboardHooks();
202
+
// Speak some text
203
+
if (SRAL_GetEngineFeatures(0) & SUPPORTS_SPEECH) {
204
+
printf("Enter the text you want to be spoken:\n");
205
+
scanf("%s", text);
206
+
SRAL_Speak(text, false);
207
+
}
208
+
209
+
// Output text to a Braille display
210
+
if (SRAL_GetEngineFeatures(0) & SUPPORTS_BRAILLE) {
211
+
printf("Enter the text you want to be shown on braille display:\n");
212
+
scanf("%s", text);
213
+
SRAL_Braille(text);
214
+
215
+
}
216
+
217
+
// Delay example
218
+
SRAL_Output("Delay example: Enter any text", false);
219
+
SRAL_Delay(5000);
220
+
SRAL_Output("Press enter to continue", false);
221
+
scanf("%s", text);
222
+
223
+
SRAL_StopSpeech(); // Stops the delay thread
224
+
// Speech rate
225
+
if (SRAL_GetEngineFeatures(0) & SUPPORTS_SPEECH_RATE) {
226
+
227
+
uint64_t rate = SRAL_GetRate();
228
+
const uint64_t max_rate = rate + 10;
229
+
for (rate; rate < max_rate; rate++) {
230
+
SRAL_SetRate(rate);
231
+
SRAL_Speak(text, false);
232
+
sleep_ms(500);
233
+
}
234
+
}
235
+
// Uninitialize the SRAL library
236
+
SRAL_Uninitialize();
237
+
238
+
return 0;
173
239
}
174
240
175
241
```
176
242
243
+
## Python
244
+
```
245
+
import time
246
+
247
+
import sral
248
+
249
+
def sleep_ms(milliseconds):
250
+
time.sleep(milliseconds / 1000.0) # Convert milliseconds to seconds
251
+
252
+
def main():
253
+
text = ""
254
+
# Initialize the SRAL library
255
+
instance = sral.Sral(32)
256
+
257
+
instance.register_keyboard_hooks()
258
+
259
+
# Speak some text
260
+
if instance.get_engine_features(0) & 128:
261
+
text = input("Enter the text you want to be spoken:\n")
262
+
instance.speak(text, False)
263
+
264
+
# Output text to a Braille display
265
+
if instance.get_engine_features(0) & 256:
266
+
text = input("Enter the text you want to be shown on braille display:\n")
267
+
instance.braille(text)
268
+
269
+
# Delay example
270
+
instance.output("Delay example: Enter any text", False)
271
+
instance.delay(5000)
272
+
instance.output("Press enter to continue", False)
273
+
input() # Wait for user to press enter
274
+
275
+
instance.stop_speech() # Stops the delay thread
276
+
277
+
# Speech rate
278
+
if instance.get_engine_features(0) & 512:
279
+
rate = instance.get_rate()
280
+
max_rate = rate + 10
281
+
for rate in range(rate, max_rate):
282
+
instance.set_rate(rate)
283
+
instance.speak(text, False)
284
+
sleep_ms(500)
285
+
286
+
# Uninitialize the SRAL library
287
+
instance = None
288
+
if __name__ == "__main__":
289
+
main() # invoke_main()
290
+
291
+
```
292
+
293
+
177
294
## Additional info
178
-
For [NVDA](https://github.com/nvaccess/nvda) screen reader, you need to download the [Controller Client](https://www.nvaccess.org/files/nvda/releases/stable/) for this.
295
+
For [NVDA](https://github.com/nvaccess/nvda) screen reader, you need to download the [Controller Client](https://www.nvaccess.org/files/nvda/releases/stable/). We don't support old client V 1.
0 commit comments