Class a.s.SpeechChannel(object):

Part of aculab.speech View Source View In Hierarchy

A full duplex Prosody channel.

Logging: SpeechChannels are prefixed with sc- and the log name is speech.
Method __init__ Allocate a full duplex Prosody channel.
Method __del__ Close the channel if it is still open.
Method _close Finalizes the shutdown of a speech channel.
Method close Close the channel.
Method set_event Create and set an event for the channel.
Method tdm_connect Connect the channel to a timeslot on its DSP's timeslot range.
Method get_module Return a unique identifier for module comparisons.
Method get_switch Return a unique identifier for switch card comparisons.
Method get_timeslot Get the tx timeslot for TDM switch connections.
Method get_datafeed Get the datafeed.
Method listen_to Listen to a timeslot or a tx instance.
Method speak_to Speak to a timeslot.
Method listen_for Start DTMF/Tone detection.
Method dc_config Configure the channel for data communications.
Method start Start a job.
Method play Play a file.
Method record Record to a file.
Method tone Send a predefined output tone.
Method digits Send a string of DTMF digits.
Method silence Play silence.
Method faxrx Receive a FAX.
Method faxtx Transmit a FAX.
Method on_recog Reactor callback.
Method stop Stop the current job.
Method job_done Internal job support.
def __init__(self, controller, card=0, module=0, user_data=None, ts_type=lowlevel.kSMTimeslotTypeALaw, reactor=Reactor): (source)
Allocate a full duplex Prosody channel.
ParameterscontrollerThis object will receive notifications about completed jobs. Controllers must implement:
  • play_done(self, channel, reason, file, duration, user_data)
  • dtmf(self, channel, digit, user_data)
  • record_done(self, channel, reason, file, size, user_data)
  • digits_done(self, channel, reason, user_data).
Reason is an exception or None (for normal termination).
cardeither a card offset or a snapshot.Card instance.
moduleeither the Prosody Sharc DSP offset or a snapshot.Module instance.
user_dataThe data associated with this channel. In MVC terms, this would be the model. In most of the examples, this is Glue or a subclass.
ts_type

The encoding to use on the timeslot, either alaw, mulaw or raw data.

Related Aculab documentation: sm_config_module_switching.
reactorThe reactor used to dispatch controller methods. By default, a single Reactor is used for all channels.
def __del__(self): (source)
Close the channel if it is still open.
def _close(self): (source)

Finalizes the shutdown of a speech channel.

Do not use directly, use SpeechChannel.close.
def close(self, *args): (source)

Close the channel.

If the channel is active, all pending jobs will be stopped before the channel is freed.
Parameters*argsthis can be a list of VMPrx, VMPtx, FMPtx, FMPrx, TDMtx, TDMrx, Connection or Call that will be closed when the channel is idle. . The FAX libraries in particular will gladly dump core when VMPs or FMPs are closed before the job is finished.
def set_event(self, _type): (source)

Create and set an event for the channel.

Used internally.
Parameters_typeOne of:
  • lowlevel.kSMEventTypeReadData
  • lowlevel.kSMEventTypeWriteData
  • lowlevel.kSMEventTypeRecog
def tdm_connect(self): (source)

Connect the channel to a timeslot on its DSP's timeslot range.

See ProsodyTimeslots.

Used internally.
def get_module(self): (source)
Return a unique identifier for module comparisons. Used by switching.
def get_switch(self): (source)
Return a unique identifier for switch card comparisons. Used by switching.
def get_timeslot(self): (source)
Get the tx timeslot for TDM switch connections.
def get_datafeed(self): (source)
Get the datafeed.
def listen_to(self, source): (source)
Listen to a timeslot or a tx instance.
Parameterssource

a tuple (stream, timeslot, [timeslot_type]) or a transmitter instance (VMPtx, FMPtx or TDMtx), which must be on the same module.

Applications should normally use switching.connect.
def speak_to(self, sink): (source)

Speak to a timeslot.

Applications should normally use switching.connect.

This is only supported on pre Prosody-X hardware; On Prosody-X, connect will automatically use the datafeed API.
Parameterssinka tuple (stream, timeslot).
def listen_for(self, toneset=0, mode=lowlevel.kSMToneDetectionMinDuration40, cptone_recognition=False, grunt_detection=False, grunt_latency=0, min_noise_level=0.0, grunt_threshold=0.0): (source)

Start DTMF/Tone detection.

Related Aculab documentation: sm_listen_for.
Parameterstonesettoneset for DTMF/tone detection. The default toneset will recognize DTMF only. The magic string 'dtmf/fax' will activate a combined DTMF/FAX toneset.
modethe algorithm to use for tone detection. See sm_listen_for for a list of available algorithms.
def dc_config(self, protocol, pconf, encoding, econf): (source)

Configure the channel for data communications.

Related Aculab documentation: smdc_channel_config.
def start(self, job): (source)

Start a job.

Only a single job may run at the same time. This is a somewhat arbitrary limitation that merely simplifies the implementation.
def play(self, file, volume=0, agc=0, speed=0, filetype=None): (source)

Play a file.

This is a shorthand to create and start a PlayJob.

See PlayJob for a description of the parameters.
def record(self, file, max_octets=0, max_elapsed_time=0.0, max_silence=0.0, elimination=0, agc=0, volume=0, filetype=None): (source)

Record to a file.

This is a shorthand to create and start a RecordJob.

See RecordJob for a description of the parameters.
def tone(self, tone, duration=0.0): (source)

Send a predefined output tone.

This is a shorthand to create and start a ToneJob.

See ToneJob for a description of the parameters.
def digits(self, digits, inter_digit_delay=0, digit_duration=0): (source)

Send a string of DTMF digits.

This is a shorthand to create and start a DigitsJob.

See DigitsJob for a description of the parameters.
def silence(self, duration=0.0): (source)

Play silence.

This is a shorthand to create and start a SilenceJob.
def faxrx(self, file, subscriber_id='', transport=(None, None), trace=None): (source)
Receive a FAX.
ParametersfileThe name of a TIFF file that will receive the image.
subscriber_idThe alphanumerical id of the station.
transportA pair of (vmptx, vmprx) or (fmptx, fmprx) if this FAX is to be received on a RTP/UDPTL connection.
traceFile name of a trace file. Default is None
def faxtx(self, file, subscriber_id='', transport=(None, None), trace=None): (source)
Transmit a FAX.
ParametersfileThe name of a TIFF file that contains the image to send.
subscriber_idThe alphanumerical id of the station.
transportA pair of (vmptx, vmprx) or (fmptx, fmprx) if this FAX is to be sent on a RTP/UDPTL connection.
traceFile name of a trace file. Default is None
def on_recog(self): (source)

Reactor callback.

Called when a DTMF digit or a tone is recognised.
def stop(self): (source)
Stop the current job.
def job_done(self, job, fn, reason, *args, **kwargs): (source)
Internal job support.
API Documentation for pyAculab, generated by pydoctor at 2009-01-02 15:12:29.