Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exceptions

The subclasses of PrismError are defined in prism.common.

prism.common.PrismError

Base class of the exceptions that report Prism errors.

Syntax

class PrismError(code: int, message: str | None = None)

Parameters

code

The numeric PrismError value.

message

The description of the error. If None, the string form of the exception gives the numeric value.

Attributes

code

The numeric PrismError value.

message

The description of the error, or None. It is the result of prism_error_string for errors reported by Prism, and a description of the binding’s own for errors the binding detects.

Remarks

Each PrismError value of the C API other than PRISM_OK has a subclass named after it; PRISM_ERROR_NOT_IMPLEMENTED is reported as PrismNotImplementedError. Values unknown to this version of the binding are reported as PrismUnknownError. Subclasses also derive from the built-in exception closest in meaning, where there is one, so that PrismNotImplementedError is a NotImplementedError and PrismInvalidParamError is a ValueError.

A custom backend MAY raise these exceptions to report a specific error; see prism.CustomBackend.

prism.common.PrismNotInitializedError

The backend is not initialized.

Syntax

class PrismNotInitializedError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_NOT_INITIALIZED. Backends are initialized when they are obtained, so this error is not ordinarily seen.

prism.common.PrismAlreadyInitializedError

The backend is already initialized.

Syntax

class PrismAlreadyInitializedError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_ALREADY_INITIALIZED. The binding treats this error as success when it initializes a backend, so it is not ordinarily seen.

prism.common.PrismInvalidOperationError

The operation is invalid in the current state.

Syntax

class PrismInvalidOperationError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_INVALID_OPERATION. Raised, among other cases, when a registry builder is given a backend whose name or identifier it already contains.

prism.common.PrismInternalError

An internal error occurred.

Syntax

class PrismInternalError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_INTERNAL. Also reported for a custom backend method that raises an exception with no more specific error.

prism.common.PrismBackendNotAvailableError

The backend is not available on this system.

Syntax

class PrismBackendNotAvailableError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_BACKEND_NOT_AVAILABLE. A component the backend requires is missing or not running. The backend object remains valid but cannot produce output.

prism.common.PrismNotImplementedError

The backend does not support the operation.

Syntax

class PrismNotImplementedError(PrismError, NotImplementedError)

Remarks

Reports PRISM_ERROR_NOT_IMPLEMENTED. Support for each operation is reported by prism.Backend.features.

prism.common.PrismInvalidParamError

An argument is invalid.

Syntax

class PrismInvalidParamError(PrismError, ValueError)

Remarks

Reports PRISM_ERROR_INVALID_PARAM. Also raised by the binding, without calling Prism, for text that is empty or contains a NUL character.

prism.common.PrismRangeError

An argument is outside its valid range.

Syntax

class PrismRangeError(PrismError, IndexError)

Remarks

Reports PRISM_ERROR_RANGE_OUT_OF_BOUNDS. Raised for a voice parameter outside [0.0, 1.0] and for an out-of-range voice index.

prism.common.PrismInvalidUtf8Error

A string is not valid UTF-8.

Syntax

class PrismInvalidUtf8Error(PrismError, UnicodeError)

Remarks

Reports PRISM_ERROR_INVALID_UTF8. Text passed through the binding is encoded from str, so this error arises only from text produced elsewhere, such as backend names in a shared library.

prism.common.PrismNotSpeakingError

No speech is in progress.

Syntax

class PrismNotSpeakingError(PrismError)

Remarks

Reports PRISM_ERROR_NOT_SPEAKING.

prism.common.PrismNotPausedError

Speech is not paused.

Syntax

class PrismNotPausedError(PrismError)

Remarks

Reports PRISM_ERROR_NOT_PAUSED.

prism.common.PrismAlreadyPausedError

Speech is already paused.

Syntax

class PrismAlreadyPausedError(PrismError)

Remarks

Reports PRISM_ERROR_ALREADY_PAUSED.

prism.common.PrismSpeakError

Speech synthesis failed.

Syntax

class PrismSpeakError(PrismError, IOError)

Remarks

Reports PRISM_ERROR_SPEAK_FAILURE.

prism.common.PrismNoVoicesError

The backend has no voices.

Syntax

class PrismNoVoicesError(PrismError)

Remarks

Reports PRISM_ERROR_NO_VOICES.

prism.common.PrismVoiceNotFoundError

The voice does not exist.

Syntax

class PrismVoiceNotFoundError(PrismError, LookupError)

Remarks

Reports PRISM_ERROR_VOICE_NOT_FOUND. Backends report an out-of-range voice index either as this error or as PrismRangeError.

prism.common.PrismMemoryError

Memory allocation failed.

Syntax

class PrismMemoryError(PrismError, MemoryError)

Remarks

Reports PRISM_ERROR_MEMORY_FAILURE.

prism.common.PrismUnknownError

An unclassified error occurred.

Syntax

class PrismUnknownError(PrismError)

Remarks

Reports PRISM_ERROR_UNKNOWN. Also reported for error values unknown to this version of the binding.

prism.common.PrismInvalidAudioFormatError

The audio format is not one Prism can handle.

Syntax

class PrismInvalidAudioFormatError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_INVALID_AUDIO_FORMAT. The speech engine or voice uses an audio format Prism cannot convert, or reported format parameters that are not meaningful.

prism.common.PrismInternalBackendLimitExceededError

The backend’s instance limit would be exceeded.

Syntax

class PrismInternalBackendLimitExceededError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_INTERNAL_BACKEND_LIMIT_EXCEEDED. The backend allows only a fixed number of instances to exist at once.

prism.common.PrismBackendEnteredUndefinedStateError

The backend is in an undefined state.

Syntax

class PrismBackendEnteredUndefinedStateError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_BACKEND_ENTERED_UNDEFINED_STATE. An operation failed in a way that left the backend unusable. The backend MUST NOT be used further.

prism.common.PrismLibraryLoadFailedError

A shared library could not be opened.

Syntax

class PrismLibraryLoadFailedError(PrismError, OSError)

Remarks

Reports PRISM_ERROR_LIBRARY_LOAD_FAILED. The file does not exist, is not a loadable library, was built for another architecture, or failed to initialize.

prism.common.PrismLibraryInvalidError

A shared library is not a Prism plugin.

Syntax

class PrismLibraryInvalidError(PrismError, ImportError)

Remarks

Reports PRISM_ERROR_LIBRARY_INVALID. The library does not export prism_plugin_query.

prism.common.PrismIncompatibleAbiError

A plugin is incompatible with this version of Prism.

Syntax

class PrismIncompatibleAbiError(PrismError, RuntimeError)

Remarks

Reports PRISM_ERROR_INCOMPATIBLE_ABI. The plugin declined the host, or declared a plugin ABI generation this version does not accept.