eSpeak NG Loader

0.2.4 · active · verified Wed Apr 15

eSpeak NG Loader is a Python package (version 0.2.4, released January 16, 2025) designed to dynamically load the eSpeak NG shared library, making it available for other Python libraries or applications that require eSpeak NG functionality. It simplifies the process of interacting with the underlying C library, abstracting away platform-specific loading mechanisms. The project demonstrates an active release cadence with recent updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to retrieve the path to the eSpeak NG shared library using `get_library_path()` and how to load it directly into your Python process with `load_library()`. It also includes guidance on the essential prerequisite of having the eSpeak NG library installed on the system.

import os
from espeakng_loader import get_library_path, load_library, make_library_available

try:
    # Get the path to the loaded eSpeak NG shared library
    library_path = get_library_path()
    print(f"eSpeak NG library path: {library_path}")

    # Example: Directly load the library (returns a ctypes.CDLL object)
    # This is useful if you're writing a direct binding or need the CDLL object.
    espeak_ng_cdll = load_library()
    print(f"eSpeak NG library loaded directly: {espeak_ng_cdll}")
    
    # Example: Make the library available for other systems (e.g., via PATH on Windows/LD_LIBRARY_PATH on Linux)
    # This is typically handled implicitly or by other Python bindings.
    # make_library_available()
    # print("eSpeak NG library made available to system.")

    # Note: To actually use eSpeak NG to speak text, you would typically
    # use another Python package that provides bindings to the C library,
    # like 'espeakng' (pip install espeakng).

except RuntimeError as e:
    print(f"Error: {e}")
    print("Please ensure the eSpeak NG shared library is installed on your system.")
    print("On Ubuntu/Debian: sudo apt-get install espeak-ng")
    print("On Windows, download installer from https://github.com/espeak-ng/espeak-ng/releases")

view raw JSON →