banterbot.handlers package

banterbot.handlers.speech_recognition_handler module

class banterbot.handlers.speech_recognition_handler.SpeechRecognitionHandler(recognizer: SpeechRecognizer, queue: CloseableQueue)[source]

Bases: object

A single-use class that handles the speech recognition process. It is typically returned by the listen method of the SpeechRecognitionService class. It can be iterated over to yield the sentences as they are recognized. It can also be closed to stop the speech recognition process.

close() None[source]

Closes the speech synthesis process.

banterbot.handlers.speech_synthesis_handler module

class banterbot.handlers.speech_synthesis_handler.SpeechSynthesisHandler(phrases: list[Phrase], synthesizer: SpeechSynthesizer, queue: CloseableQueue)[source]

Bases: object

A single-use class that handles the speech synthesis process. It is typically returned by the speak method of the SpeechSynthesisService class. It can be iterated over to yield the words as they are synthesized. It can also be closed to stop the speech synthesis process.

banterbot.handlers.stream_handler module

class banterbot.handlers.stream_handler.StreamHandler(interrupt: Number, kill_event: Event, queue: CloseableQueue, processor_thread: Thread, shared_data: dict)[source]

Bases: object

Handler for managing and interacting with a data stream.

interrupt(kill: bool = False) None[source]

Interrupt the active stream by setting the interrupt value to the current time and setting the kill event.

Parameters:

kill (bool) – Whether to kill the queue or not. Defaults to False.

is_alive() bool[source]

Returns whether the stream handler is alive or not.

Returns:

Whether the stream handler is alive or not.

Return type:

bool