The scanner Module

A Scanner searches for a phrase, or multiple phrases, in the decoded audio.

For WORD scans, the most likely decoded hypothesis is searched.

For LATTICE scans, all possibilities in the client.lattice.Lattice are searched.

When a callback is provided, it will be called for each match found. Arguments passed are the Scanner object, the phrase found, the containing Utterance and the start time of the matching phrase. For LATTICE scans, an additional argument, the confidence score of the matching phrase, will be passed to the callback.

Scans can be performed on active streams or previously decoded data and can be paused, resumed and closed.

scanner Methods

client.scanner.scanwords(source, phrases, callback=None)

Continuously scan decoded words for given phrase(s) and when match is found, call callback with (Scanner, phrase, time, Utterance). If no callback is supplied, then defaults to printing matches and is blocking.

Return newly created Scanner object.

client.scanner.scanlattice(source, phrases, callback=None)

Continuously scan whole decoded lattice for given phrase(s). When match is found, call callback with (Scanner, phrase, time, Utterance, confidence). If no callback is supplied, then defaults to printing matches and is blocking.

Returns newly created Scanner object.

client.scanner.scantype(stype, source, targets, callback=None)

Continuously scan source for given stype target(s) and when match is found, call callback. The source type, stype, is either WORD or LATTICE. If no callback is supplied, then defaults to printing matches and is blocking.

Returns newly created Scanner object.

scanner Enumerations

client.scanner.ScanType
The type of scan to perform, either WORD or LATTICE.
client.scanner.ScanStatus
The Scanner status, one of ACTIVE, PAUSED, DONE.

Scanner Objects

class client.scanner.Scanner(source, stype, targets, callback)

Scans through specified source for given targets.

Constructor creates and starts a scanner with the specified source, stype, targets, and callback. The source is a client.stream.Stream, client.speechdata.SpeechData, or decoded file from client.speechdata.SpeechData.dump(). The source type, stype, is either WORD or LATTICE.

targets is the phrase or list of phrases for which to scan. A phrase is a space delimited string of one or more words.

callback is the function to be called when matches occur. For WORD scans, called with (Scanner, target, time, Utterance). For LATTICE scans, called with (Scanner, target, time, Utterance, confidence). When scan is done, will be called with None for non-Scanner fields.

num_matches
number of matches found so far
status
ScanStatus, one of ACTIVE, PAUSED, DONE.
iswordtype()
Return True if the Scanner’s type is WORD.
islatticetype()
Return True if the Scanner’s type is LATTICE.
isdone()
Return True if scanning is finished.
isactive()
Return True if scanning is active.
ispaused()
Return True if scanning is paused.
pause()
Pause scanning after current utterance (if any). Return False if not active.
resume(fromtime=None)
Resume scanning. Return False if scan was not paused. If fromtime is None, the default, scan all utterances since pause. If fromtime is a datetime, skip all utterances (up to current) that end before fromtime. If fromtime is -1, skip to current.
close()
Permanently stop scanner. Return False if already done.
join()
Wait until scanner finishes.

Module Quick Links

Table Of Contents

Previous topic

The utterance Module

Next topic

The streamlistener Module

This Page