Ben Kramer > ctserver-0.3 > Telephony::CTPort

Download:
ctserver-0.3.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.3   Source  

NAME ^

Telephony::CTPort - Computer Telephony programming in Perl

SYNOPSIS ^

 use Telephony::CTPort;

 $ctport = new Telephony::CTPort(1200); # first port of CT card
 $ctport->off_hook;
 $ctport->play("beep");                 
 $ctport->record("prompt.wav",5,"");    # record for 5 seconds
 $ctport->play("prompt.wav");           # play back
 $ctport->on_hook;

DESCRIPTION ^

This module implements an Object-Oriented interface to control Computer Telephony (CT) card ports using Perl. It is part of a client/server library for rapid CT application development using Perl.

AUTHOR ^

David Rowe, david@voicetronix.com.au

CONSTRUCTOR ^

new Telephony::CTPort(SERVER_PORT);

Connects Perl client to the "ctserver" server via TCP/IP port SERVER_PORT, where SERVER_PORT=1200, 1201,..... etc for the first, second,..... etc CT ports.

METHODS ^

event() - returns the most recent event, or undef if no events pending.

off_hook() - takes port off hook, just like picking up the phone.

on_hook() - places the port on hook, just like hanging up.

wait_for_ring() - blocks until port detects a ring, then returns. The caller ID (if present) will be returned.

wait_for_dial_tone() - blocks until dial tone detected on port, then returns.

play($files) - plays audio files, playing stops immediately if a DTMF key is pressed. The DTMF key pressed can be read using the event() member function. If $ctport->event() is already defined it returns immediately. Any digits pressed while playing will be added to the digit buffer.

Filename extensions:

Searches for file in:

You can play multiple files, e.g.

$ctport->play("Hello World");

(assumes you have Hello.au and World.au files available)

You can "speak" a limited vocab, e.g.

$ctport->play("1 2 3");

(see /var/ctserver/UsMEng directory for the list of included files that define the vocab)

record($file_name, $time_out, $term_keys) - records $file_name for $time_out seconds or until any of the digits in $term_keys are pressed. The path of $file_name is considered absolute if there is a leading /, otherwise it is relative to the current directory.

ctsleep($seconds) - blocks for $seconds, unless a DTMF key is pressed in which case it returns immediately. If $ctport->event() is already defined it returns immediately without sleeping.

clear() - clears any pending events, and clears the DTMF digit buffer.

collect($max_digits, $max_seconds) - returns up to $max_digits by waiting up to $max_seconds. Will return as soon as either $max_digits have been collected or $max_seconds have elapsed. On return, the event() method will return undefined.

DTMF digits pressed at any time are collected in the digit buffer. The digit buffer is cleared by the clear() method. Thus it is possible for this function to return immediately if there are already $max_digits in the digit buffer.

dial($number) - Dials a DTMF string. Valid characters are 1234567890#*,&

number() - returns a string of audio files that enable numbers to be "spoken"

e.g. number() will convert 121 into "one hundred twenty one"

e.g. ctplay("youhave " . $ctnumber($num_mails) . " mails");

(assumes files youhave.au, mails.au, and variable $num_mails exist)

set_path() - used to set the search path for audio files supplied to play()

get_inter_digit_time_out() - returns the optional inter-digit time out used with collect().

set_inter_digit_time_out($time_out) - sets the optional inter-digit time out used with collect().

syntax highlighting: