The streamlistener Module

StreamListener is a low-level object used by Scanner and SpeechData.

As the audio input is decoded, a StreamListener listens to the Stream‘s real-time decoded results and calls the specified callback function with new data for each newly decoded Utterance.

To store the decoding results, use SpeechData.

StreamListener Objects

class client.streamlistener.StreamListener(stream, callback, start=None, end=None)

Listens to stream’s real-time decoded results and calls callback with new data.

The constructor creates a StreamListener object that listens to the results of the given Stream‘s decoding as they happen. You must call client.server.Server.decodestreams() on stream before constructing a StreamListener for it.

callback will be called with (Stream, Utterance) when decoded data is received. callback will be called with Utterance = None when Stream is done. start and/or end can be set to datetimes to limit the date range of results listened to.

addcallback(callback)
Add another callback function.
removecallback(callback)
Remove given callback function. If no callbacks are left, listener will close. Return False if callback was not in callback list.
join(timeout=None)
Wait for listener to close.
islistening()
Returns True if StreamListener is currently listening to a Stream.
close()
Stop listening to stream. Return False if already closed.

Module Quick Links

Table Of Contents

Previous topic

The scanner Module

Next topic

The lattice Module

This Page