watson_developer_cloud.websocket.recognize_listener module¶
-
class
RecognizeListener
(audio_source, options, callback, url, headers, http_proxy_host=None, http_proxy_port=None)[source]¶ Bases:
object
-
send
(data, opcode=1)[source]¶ Send message to server.
- data: message to send. If you set opcode to OPCODE_TEXT,
- data must be utf-8 string or unicode.
opcode: operation code of data. default is OPCODE_TEXT.
-
on_open
(ws)[source]¶ Callback executed when a connection is opened to the server. Handles streaming of audio to the server.
Parameters: ws – Websocket client
-
on_data
(ws, message, message_type, fin)[source]¶ Callback executed when message is received from the server.
Parameters: - ws – Websocket client
- message – utf-8 string which we get from the server.
- message_type – Message type which is either ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY
- fin – continue flag. If 0, the data continues.
-