karen.handlers

General handlers for TCP requests between device containers and the Brain.

brain_handleAudioInputData(jsonRequest)

Accepts incoming speech-to-text samples, saves them to the data catalog, and processes to determine appropriate response.

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success else raises an exception.

brain_handleKillAllCommand(jsonRequest)

Sends KILL signal to all connected devices and terminates local instance upon completion.

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success and False on failure.

brain_handleRelayCommand(jsonRequest)

Relays a command received from the brain to all connected clients.

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success and False on failure.

brain_handleRelayListenerCommand(jsonRequest)

Relays an inbound request to all karen.listener.Listener devices.

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success and False on failure.

brain_handleSayData(jsonRequest)

Accepts incoming data command for speech and calls the brain's say() method.

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success and False on failure.

device_handleAudioOutCommand(jsonRequest)

Disables listening temporarily in order to not capture text going through the speaker. Expects AUDIO_OUT_START and AUDIO_OUT_END commands.

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success and False on failure.

device_handleSayCommand(jsonRequest)

Accepts the inbound SAY command and calls the say() method on the local device to send data to the speaker.

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success and False on failure.

device_handleStartStopListenerCommand(jsonRequest)

Handles an inbound START/STOP method for a listener. Stops the listening device but not the client container.

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success and False on failure.

handleKillCommand(jsonRequest)

Stops the TCP server and all dependent services

Parameters:
  • jsonRequest (karen.shared.KJSONRequest) – Object containing the inbound JSON request

Returns:
  • (bool) – True on success and False on failure.