API Documentation (Beta)

play

Description

int play ( string $file [, bool $cache [, int $streampos [, int $barge_in [, int $time_out [, string $grammar]]]]] )

play ouputs the synthesized text-to-speech content of file.

Parameters

file

This specifies the URI from where the file to be rendered should be fetched. The file needs to be in the following formats:

  • - 16bit, 8Khz, Mono, PCM Wave files
  • - 16bit, 8Khz, Mono PCM Raw files

cache

This specifies whether the file specified above should be used from the VoicePHP cache or should be fetched. A value of TRUE indicates using the cache for file content while a value of FALSE means fetch the file from the URL. Be default, the file is read from cache (i.e. it is set to TRUE)

streampos

This specifies the relative position in the file from where the file playback should happen. It should be specified as the time offset in milliseconds. e.g. a value of 5000 means start the file playback from the 5000ms offset in the file.

barge_in

This controls whether or not the caller will be able to interrupt the speech output with a DTMF keypress or voice utterance.By default, this value is set to 0. i.e. it forces the caller to listen to entire text before being allowed to give input.

If you wish to enable it, following options can be set.

Pre-defined barge_in() bit options
name description
Bit 0 When this bit is set, the caller can interrupt the speech output.
Bit 1 When set, it specifies that DTMF keypresses can be used for interruption
Bit 2 When set, it specifies that Voice utterance can be used for interruption.

time_out

This specifies the amount of time in seconds that VoicePHP will attempt to wait for receiving inputs from the user before returning. By default, timeout is set to 5 sec.

grammar

This specifies the grammar to be used. Grammar can be either DTMF or Speech. This is required if the barge_in parameter is set to to 2. If this is not set, barge_in will defaults to DTMF.

Returns user input.