The speechdata Module

A SpeechData object provides access to and storage of recognition results.

Decoding results are separated into utterances (client.utterance.Utterance instances) and stored in a time-ordered list (SpeechData.utterances). The list of utterances is asynchronously updated as results are received. For manual control of when updates happen, the SpeechData object may be frozen and then refreshed when appropriate.

The following code constructs a SpeechData object for a client.stream.Stream stream, waits until all the results have been collected (SpeechData.join), and then prints out each utterance:

sd = SpeechData(stream) 
sd.join()       
for u in sd.utterances: print u

speechdata Enumerations

client.speechdata.SDStatus
The SpeechData status, one of ACTIVE, FROZEN, DONE, FROZENDONE.

SpeechData Objects

class client.speechdata.SpeechData(source, start=None, end=None)

Constructor creates a SpeechData object from given source which is either a client.stream.Stream or a decoded file (generated by dump).

The decoded results are stored in the utterances list. This list is updated asynchronously by default. For synchronous updating, use freeze and refresh.

Optional arguments start and/or end can be set to datetimes to filter out results outside the date range. If start or end is set to None, no filtering is done in that direction.

utterances
time ordered list of client.utterance.Utterance objects. When status is ACTIVE, this list will grow as results become available.
status
SDStatus status of SpeechData object, one of ACTIVE, FROZEN, DONE, FROZENDONE.
load(filename)
Load utterance data from decoded file (generated by dump) and add it to utterance list.
dump(filename, mode='w')
Store utterance data in a file.
isactive()
Return True if utterances list is actively being updated.
isfrozen()
Return True if utterances list is frozen (not being updated).
isdone()
Return True if utterances list is complete.
freeze()
If source is still active, stop updating utterances list with newly decoded data. Return False if source is not active (i.e. already frozen or done).
thaw()
Resume updating utterances list with newly decoded data. Return False if source is not frozen.
refresh()
Manually refresh utterances list with any newly decoded data (for use with freeze). Return True if source is frozen and there is newly decoded data available.
getrange(start=None, end=None)
Return (start, end) indices to utterances corresponding to date range [start, end).
getutterances(start=None, end=None, *metadatas)
Return a copy of utterances optionally filtered to be within date range [start, end). If a metadata dictionary is passed, then only utterances with matching metadata are included. If given multiple metadatas, include the union of their respective matches.
flat_utterance(start=None, end=None, *metadatas)
Return an utterance which combines all utterance data within the date range [start, end). If a metadata dictionary is passed, then only combine matching utterances. If given multiple metadatas, combine the union of their respective matches.
clear(start=None, end=None)
Clear all utterances ending within range [start, end).
join(timeout=None)
Wait for speech data to be completed. When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof).

Module Quick Links

Table Of Contents

Previous topic

The stream Module

Next topic

The utterance Module

This Page