Skip to main content

SpeechCore API Documentation

Overview

SpeechCore is a cross-platform Python wrapper for screen reader and text-to-speech functionality. It provides a unified interface for speech synthesis, voice control, and braille output across different operating systems. The library supports multiple speech drivers and includes Windows-specific SAPI (Speech API) functionality.

Installation

pip install speechcore

Classes

SpeechCore

Main class for speech synthesis and screen reader functionality. Only one instance may exist at a time.

Context Manager Support: Can be used with with statement for automatic initialization and cleanup.

with SpeechCore() as speech:
    speech.output("Hello, world!")

Sapi

Windows-only class providing direct access to Microsoft's Speech API (SAPI). Only available on Windows platforms.

Context Manager Support: Can be used with with statement for automatic initialization and cleanup.

# Windows only
with Sapi() as sapi:
    sapi.speak("Hello from SAPI!")

SpeechCore Methods

Initialization and Management

SpeechCore.init()

Initialize the SpeechCore library.

  • Returns: None
  • Raises: InitializationError if initialization fails

SpeechCore.free()

Free resources and shutdown the library.

  • Returns: None

SpeechCore.is_loaded() -> bool

Check if SpeechCore is currently loaded and initialized.

  • Returns: bool - True if loaded, False otherwise

Driver Management

detect_driver() -> None

Automatically detect and set the best available speech driver.

  • Returns: None

get_driver(index: int) -> str

Get the name of a speech driver by index.

  • Parameters:
    • index (int): Driver index
  • Returns: str - Driver name

current_driver() -> str

Get the name of the currently active speech driver.

  • Returns: str - Current driver name

set_driver(index: int) -> None

Set the active speech driver by index.

  • Parameters:
    • index (int): Driver index to activate
  • Returns: None

get_drivers() -> int

Get the total number of available speech drivers.

  • Returns: int - Number of available drivers

Voice Management

get_voice(index: int) -> str

Get the name of a voice by index.

  • Parameters:
    • index (int): Voice index
  • Returns: str - Voice name

get_current_voice() -> str

Get the name of the currently active voice.

  • Returns: str - Current voice name

set_voice(index: int) -> None

Set the active voice by index.

  • Parameters:
    • index (int): Voice index to activate
  • Returns: None

get_voices() -> int

Get the total number of available voices.

  • Returns: int - Number of available voices

Audio Control

set_volume(offset: float) -> None

Set the speech volume level.

  • Parameters:
    • offset (float): Volume level (typically 0.0 to 1.0)
  • Returns: None

get_volume() -> float

Get the current speech volume level.

  • Returns: float - Current volume level

set_rate(offset: float) -> None

Set the speech rate (speed).

  • Parameters:
    • offset (float): Speech rate value
  • Returns: None

get_rate() -> float

Get the current speech rate.

  • Returns: float - Current speech rate

Speech Output

output(text: str, interrupt: bool = False) -> bool

Speak the given text.

  • Parameters:
    • text (str): Text to speak
    • interrupt (bool): Whether to interrupt current speech (default: False)
  • Returns: bool - True if successful

output_braille(text: str) -> bool

Output text to braille display.

  • Parameters:
    • text (str): Text to output to braille
  • Returns: bool - True if successful

output_file(filename: str, text: str) -> None

Save speech output to an audio file.

  • Parameters:
    • filename (str): Output file path
    • text (str): Text to convert to audio
  • Returns: None

Playback Control

resume() -> None

Resume paused speech.

  • Returns: None

pause() -> None

Pause current speech.

  • Returns: None

stop() -> None

Stop current speech immediately.

  • Returns: None

is_speaking() -> bool

Check if speech is currently active.

  • Returns: bool - True if speaking, False otherwise

System Information

get_speech_flags() -> int

Get current speech system capability flags.

  • Returns: int - Bitfield of capability flags

check_speech_flags(flags: int) -> bool

Check if specific speech flags are set.

  • Parameters:
    • flags (int): Flags to check
  • Returns: bool - True if flags are set

Sapi Methods (Windows Only)

Initialization

Sapi.init()

Initialize the SAPI interface.

  • Returns: None
  • Raises: InitializationError if initialization fails
  • Raises: NotImplementedError on non-Windows platforms

Sapi.release()

Release SAPI resources.

  • Returns: None

Sapi.sapi_loaded() -> bool

Check if SAPI is currently loaded.

  • Returns: bool - True if loaded, False otherwise

Voice Control

voice_set_rate(offset: float) -> None

Set SAPI voice speech rate.

  • Parameters:
    • offset (float): Speech rate value
  • Returns: None

voice_get_rate() -> float

Get current SAPI voice speech rate.

  • Returns: float - Current speech rate

voice_set_volume(offset: float) -> None

Set SAPI voice volume level.

  • Parameters:
    • offset (float): Volume level
  • Returns: None

voice_get_volume() -> float

Get current SAPI voice volume level.

  • Returns: float - Current volume level

get_voice(index: int) -> str

Get SAPI voice name by index.

  • Parameters:
    • index (int): Voice index
  • Returns: str - Voice name

get_current_voice() -> str

Get current SAPI voice name.

  • Returns: str - Current voice name

set_voice_by_index(index: int) -> None

Set SAPI voice by index.

  • Parameters:
    • index (int): Voice index
  • Returns: None

set_voice(voice_name: str) -> None

Set SAPI voice by name.

  • Parameters:
    • voice_name (str): Name of voice to set
  • Returns: None

get_voices() -> int

Get number of available SAPI voices.

  • Returns: int - Number of voices

SAPI Speech Output

speak(text: str, interrupt: bool = False, xml: bool = False) -> None

Speak text using SAPI.

  • Parameters:
    • text (str): Text to speak
    • interrupt (bool): Whether to interrupt current speech (default: False)
    • xml (bool): Whether text contains SSML markup (default: False)
  • Returns: None

output_file(filename: str, text: str, xml: bool = False) -> None

Save SAPI speech to audio file.

  • Parameters:
    • filename (str): Output file path
    • text (str): Text to convert
    • xml (bool): Whether text contains SSML markup (default: False)
  • Returns: None

SAPI Playback Control

resume() -> None

Resume paused SAPI speech.

  • Returns: None

pause() -> None

Pause current SAPI speech.

  • Returns: None

stop() -> None

Stop current SAPI speech.

  • Returns: None

Constants

Speech capability flags available from __speech_common:

  • SC_SPEECH_FLOW_CONTROL - Speech flow control support
  • SC_SPEECH_PARAMETER_CONTROL - Speech parameter control support
  • SC_VOICE_CONFIG - Voice configuration support
  • SC_FILE_OUTPUT - File output support
  • SC_HAS_SPEECH - Speech synthesis support
  • SC_HAS_BRAILLE - Braille output support
  • SC_HAS_SPEECH_STATE - Speech state monitoring support

Exceptions

InitializationError

Raised when SpeechCore or SAPI initialization fails.

NotLoadedError

Raised when attempting to use methods before proper initialization.

Example Usage

from speechcore import SpeechCore

# Basic usage with context manager
with SpeechCore() as speech:
    speech.output("Hello, this is SpeechCore!")
    
    # Check available voices
    voice_count = speech.get_voices()
    for i in range(voice_count):
        print(f"Voice {i}: {speech.get_voice(i)}")
    
    # Adjust speech parameters
    speech.set_rate(0.5)  # Slower speech
    speech.set_volume(0.8)  # Lower volume
    
    speech.output("This is slower and quieter speech.")

# Windows-specific SAPI usage
if sys.platform == "win32":
    from speechcore import Sapi
    
    with Sapi() as sapi:
        sapi.speak("Hello from Windows SAPI!")

Metadata

Release files for SpeechCore 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for SpeechCore 1.1.1
File Actions
speechcore-1.1.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for speechcore-1.1.1-cp313-cp313-win_amd64.whl
speechcore-1.1.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for speechcore-1.1.1-cp312-cp312-win_amd64.whl
speechcore-1.1.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for speechcore-1.1.1-cp311-cp311-win_amd64.whl
speechcore-1.1.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for speechcore-1.1.1-cp310-cp310-win_amd64.whl
speechcore-1.1.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for speechcore-1.1.1-cp39-cp39-win_amd64.whl
speechcore-1.1.1-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for speechcore-1.1.1-cp38-cp38-win_amd64.whl

Total release size: 4.3 MB

Release files / speechcore-1.1.1-cp313-cp313-win_amd64.whl

Download URL speechcore-1.1.1-cp313-cp313-win_amd64.whl
Size 715.5 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
b813002990b8a4cbd27b3cdd99caf36ce2d3c22ee1330ca4b8b724889d0a7657
BLAKE2b-256 checksum
How to use checksums
872d597bbfdbab2b168d3edd5383c8d514a41be02db77f9e6d4e3ba5af7da5e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / speechcore-1.1.1-cp312-cp312-win_amd64.whl

Download URL speechcore-1.1.1-cp312-cp312-win_amd64.whl
Size 715.4 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
5cd4c821f2da875ec916e8e269fca85171eedc44799f56c287601260a84c90f0
BLAKE2b-256 checksum
How to use checksums
0f916b7a4ae61f9cfbe0709cab2ef0370909ec4071b58bcb7c4cc4abf2ab7ee6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / speechcore-1.1.1-cp311-cp311-win_amd64.whl

Download URL speechcore-1.1.1-cp311-cp311-win_amd64.whl
Size 714.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
32a738d45f0a2f8a04e73f980801741080341e2a7701b58d83d7b721c5d06997
BLAKE2b-256 checksum
How to use checksums
e39f33f8a81e816ff11165e1c353e89d113b654a46f6a33eedbefd59a31cb7cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / speechcore-1.1.1-cp310-cp310-win_amd64.whl

Download URL speechcore-1.1.1-cp310-cp310-win_amd64.whl
Size 713.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
06a10ed99ff3977e3e9a9cf76b85996259fed39861bb0fa0d98abe6c840a805c
BLAKE2b-256 checksum
How to use checksums
3730689ea1c0ddaee691992ae94001cae283b28255246f9cf9ef1515871eefa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / speechcore-1.1.1-cp39-cp39-win_amd64.whl

Download URL speechcore-1.1.1-cp39-cp39-win_amd64.whl
Size 715.4 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
132e19bbc92f483792202225bf9d147804740f70ca5af26ef12ff775dde352af
BLAKE2b-256 checksum
How to use checksums
e6bfa1766f060cf2e57f0af691e7dc9330c7f6d2214e3d162e52cba73fe002d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / speechcore-1.1.1-cp38-cp38-win_amd64.whl

Download URL speechcore-1.1.1-cp38-cp38-win_amd64.whl
Size 713.1 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
0c9f9b4639725de4b28c563e440e4f685fd3a52df9e62c338ead541f4ce423b9
BLAKE2b-256 checksum
How to use checksums
9ff6fd8900c2249221f22bceabb79455adcd9c8bec8c5515fc6d3937d2f07975
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Security for SpeechCore 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page