A cython wrapper over the tolk library
Project description
Cytolk
A cython wrapper over the tolk library.
Installation
You can install cytolk with
pip install cytolk
Building from source
make sure to clone this repository recursively, as this repository depends on the original tolk repo
git clone --recursive https://github.com/pauliyobo/cytolk
Then run
python setup.py install
Note: this will build the extension using the generated c code present in the repository. By doing so you are not required to have cython installed on your machine. If you would like to build directly from the .pyx file, you will have to install the requirements which as of now are only cython and setuptools
pip install -r requirements.txt
And set the environment variable BUILD_CYTOLK
set BUILD_CYTOLK=1
Usage
As of 0.1.7 it is now possible to use a context manager to utilize tolk's functionality. Using tolk.load() and tolk.unload() is still possible.
# This example makes use of tolk's context manager
# The old example can be found in the examples directory in the file named tolk_example.py
# They are exactly the same, only difference being that the old one does not use the context manager
from cytolk import tolk
# No need to load or unload anything, let the manager handle it for us
with tolk.tolk():
# detect the screenreader in use, in my case NVDA
print(f"screenreader detected is {tolk.detect_screen_reader()}")
# does this screenreader suport speech and braille?
if tolk.has_speech():
print("this screenreader supports speech")
if tolk.has_braille():
print("this screenreader supports braille")
# let's speak some text
tolk.speak("hello")
# good, let's now output some text on the braille display, if any in use
tolk.braille("hello")
Note
The library will not work if it can not interface to your current screen reader. Therefore, you must place the appropriate DLL that interfaces to your screen reader in your working directory. Cytolk comes already packed with the NVDA DLLs.
Placing required DLLs
Note: as of cytolk 0.1.6 placing the DLLs is no longer required, as the library automatically modifies the search path to detect the DLLs that are packaged with the extension itself Cytolk needs to find the required DLLs so that the wrapped c library can interface to your current screen reader. For this to work, the libraries need to be placed in the directory where your program is running. Finding those libraries can be annoying some times, and so, the wheel you install already comes packaged with the libraries you will need based on your architecture. This means that if you are using a 32 bit version of python, the libraries you will find in the wheel you install will be only 32 bit. But how do we go about doing this? Easy. Cytolk provides also a command line interface, which allows you to just do that. What you are looking for is this:
python -m cytolk --place_dll
This command will just place the required libraries you will need in your current directory, avoiding you to have to copy them manually. Suggestion to make this process easier are welcome.
Using with PyInstaller
Cytolk can't normally be included in a pyinstaller bundled executable because pyinstaller does not know which libraries it needs to collect. To fix this, it is possible to use a hook that ells pyinstaller which libraries to collect.
To use the hook, you will have to manually copy pyinstaller_hooks/hook-cytolk.py
in the pyinstaller hooks folder.
Using with Nuitka
As of 0.1.11 It is also possible to include cytolk in an application that uses nuitka to build an executable.
However, while in pyinstaller's case it was a matter of just copying a file, with nuitka one more step must be applied.
Due to the fact that when c extensions are linked to an executable they can not use the special __file__
attribute, you must disable the extension of the search path when loading cytolk. To do so you can either do:
tolk.load(False)
# code
tolk.unload()
Or
with tolk.tolk(False):
# code
Assuming that is done, you can copy the plugin in the directory nuitka_plugins
and to build the executable make sure to pass the option --user-plugin=path-to-plugin
Functions
Note: some, if not all of the documentation, has been added following the already present documentation on the original tolk documentation, adapting it to the name of the functions present on this extension.
Should you be interested on more detailed documentation, you will be able to find so in the original tolk repository.
Second note: in version 0.1.7, calling functions will raise an exception if cytolk hasn't been loaded. The only functions which are not subject to this are
tolk.load
tolk.is_loaded
tolk.unload
tolk.try_sapi
tolk.prefer_sapi
tolk.load(extended_search_path: bool)
Initializes the tolk library and sets the current screenreader driver, assuming that it's present in the list of supported screenreaders. All the functions to interact with the screenreader driver must be used after tolk is initialized. to verify whether tolk is initialized, call tolk.is_loaded()
args:
- extended_search_path: allows you to decide whether the library should load trying to automatically detect the DLL libraries it depends on or not. Defaults to True.
Note: this same argument can be used in the context manager
tolk.is_loaded() -> bool
Verifies whether tolk has been initialized
tolk.unload()
deinitializes tolk.
tolk.try_sapi(try_sapi: bool)
Sets if Microsoft Speech API (SAPI) should be used in the screen reader auto-detection process. The function should be called before tolk is initialized
tolk.prefer_sapi(prefer_sapi: bool)
If auto-detection for SAPI has been turned on through tolk.try_sapi, sets if SAPI should be placed first (true) or last (false) in the screen reader detection list. Putting it last is the default and is good for using SAPI as a fallback option. Putting it first is good for ensuring SAPI is used even when a screen reader is running, but keep in mind screen readers will still be tried if SAPI is unavailable. This function triggers the screen reader detection process if needed. this function can be called before tolk is initialized
tolk.detect_screen_reader() -> Optional[str]
Returns the common name for the currently active screen reader driver, if one is set. If none is set, tries to detect the currently active screen reader before looking up the name. If no screen reader is active, None is returned. tolk.load
must be called before using this function.
tolk.has_speech() -> bool
Returns true if the current screen reader driver supports speech output. This function must be called after tolk is initialized.
tolk.has_braille() -> bool
Returns true if the current screen reader driver supports braille output. This function must be called after tolk is initialized.
tolk.output(text: str, interrupt: bool = False) -> bool
Outputs text through the current screen reader driver. Tolk.output uses both speech and braille if supported. Returns True on success False if otherwise. This function must be called after tolk is initialized.
Args:
- text: the text to output
- interrupt: interrupts any previous speech.
tolk.speak(text: str, interrupt: bool = False) -> bool
speaks the text through the current screen reader driver. Returns True on success False if otherwise. This function must be called after tolk is initialized.
Args:
- text: the text to speak
- interrupt: interrupts any previous speech.
tolk.braille(text: str) -> bool
Brailles text through the current screen reader driver. Returns True on success False if otherwise. This function must be called after tolk is initialized.
Args:
- text (str) text to braille
tolk.is_speaking() -> bool
Returns True if the current screen reader driver is speaking. This function must be called after tolk is initialized.
tolk.silence() -> bool
Silences the current screen reader driver. Returns True on success False if otherwise. This function must be called after tolk is initialized.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file cytolk-0.1.13-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 170.6 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb9ff1422d05e3176a7f1510ff2049a1d98e21f3a60da7cc5c5e82b8f6645478 |
|
MD5 | 48541470961b45f46a41bbe4dc0a19bd |
|
BLAKE2b-256 | ffd58bbed08e5efdfa4c99bd81a0c5e9543968055253c72c3120375eca0d1ecd |
File details
Details for the file cytolk-0.1.13-cp312-cp312-win32.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp312-cp312-win32.whl
- Upload date:
- Size: 211.4 kB
- Tags: CPython 3.12, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5843c025a497015b299266cd82d52632b46220103da56ca446e3987b06a86f65 |
|
MD5 | 7e43f30ab43f3dd4b55fb458a61b0697 |
|
BLAKE2b-256 | dcc368075be4c2f676bfb95aba59b1d3cfc642803c0a6ecaa158f8f45a490b26 |
File details
Details for the file cytolk-0.1.13-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 172.9 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | feb3c7b72dfd75024a0d3ac54e30148510bfc47a87e897a31c140efb851faf14 |
|
MD5 | b42c9949ce78f9f7832fc2db452e63b1 |
|
BLAKE2b-256 | b55bdd52fa0a20d3d0214e70c2a3c5b0cdaa30832c30c43fcf2493b6180b7829 |
File details
Details for the file cytolk-0.1.13-cp311-cp311-win32.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp311-cp311-win32.whl
- Upload date:
- Size: 213.1 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8acee8b09dc498c31ce4f3bdeddc1f4e5c0854e82a4c5dbd7b7b29487ee799d6 |
|
MD5 | f79947da0284ffc0df584ef3ee49f91f |
|
BLAKE2b-256 | 03bce3dc9bf2c051ae8f2275d7df1c7f634da530927f4bbe46b65192512c6d25 |
File details
Details for the file cytolk-0.1.13-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 172.8 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c33a9fdad3735378d44890a1564f60a106fc8e9ace4ed7b8a0b02d75e8ab1ab |
|
MD5 | 71b1e0598dc086f6f5cda687f64f3b55 |
|
BLAKE2b-256 | bdafb3c7fd50ced713c17abac3d9b9edec59ea321b3762f9f7820b857f38234c |
File details
Details for the file cytolk-0.1.13-cp310-cp310-win32.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp310-cp310-win32.whl
- Upload date:
- Size: 213.1 kB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d7d8f401095cf70a3c7d0409f00725bd48db9081da738093b1f0c31e2dceae3 |
|
MD5 | 082aa119922b10693063b6e48596fdb5 |
|
BLAKE2b-256 | 36e18e8818c056e0721187356f24c14f59f671c67d201b4618c211bd7c93f18c |
File details
Details for the file cytolk-0.1.13-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 181.1 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 492d8dc0e7e0e9b3a2a0ce318bdeba21d1ba8a183aad9cf5df47592e017dc4f4 |
|
MD5 | 32355cc60be953ebc3f57e62cae986ea |
|
BLAKE2b-256 | 60c8f400325d2ba79891e4db49e5d490f70745051d31291d334f4138a3a7692d |
File details
Details for the file cytolk-0.1.13-cp39-cp39-win32.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp39-cp39-win32.whl
- Upload date:
- Size: 218.6 kB
- Tags: CPython 3.9, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91892c53a0f971977ef996814212e3512953b914a0dd5378a5e3ba9ae4551eda |
|
MD5 | 8a1c4ca2c79eb35e91d37535e15bd5d4 |
|
BLAKE2b-256 | 93e4c3fb41b427117ba9a2861fa2bddc994e31737f2ce9ec6d689c2adf1ffe48 |
File details
Details for the file cytolk-0.1.13-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 181.4 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4ea013b9dd50ddf996962bd19a24b03f0beb297345b17fed5fe69dfd3f360e3 |
|
MD5 | 5ad84786c111ed467d11f73f18160e32 |
|
BLAKE2b-256 | d7115bfed17aa2109bf978ec0648d472373b39d527f067749876c0d369e591f8 |
File details
Details for the file cytolk-0.1.13-cp38-cp38-win32.whl
.
File metadata
- Download URL: cytolk-0.1.13-cp38-cp38-win32.whl
- Upload date:
- Size: 218.5 kB
- Tags: CPython 3.8, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceb1b86ecec05967946a7647b59114d1a9a03adaccea78688ae2c747a4c8552a |
|
MD5 | 5f799ad1fb41141d75bbdafd3ffa2d10 |
|
BLAKE2b-256 | f21409d1a18795078f84d90a9d25cb4a3f31155c017e7b5cfcbfaf149439b6c7 |