Avaya Logo

Previous Topic

Next Topic

Book Contents

Book Index

Voice file positioning and speech headers

Note:
The information in this section only applies to speech played and recorded on the speech resource.

The voice system uses speech headers to indicate the algorithm type of a voice object. Speech headers are 4 bytes in length and occur every 400 bytes. The irLSeek(3IRAPI) function and the count argument to the irPlay(3IRAPI) function do not account for speech file headers, so exact time positioning of the voice file pointer or play duration is not guaranteed.

The voice file headers may also pose a problem when playing from arbitrary points of a voice file if the sequence of speech objects are not all encoded with the same algorithm. This is due to the way the voice cards play speech. A voice card receives a stream of speech data from the system. When a speech header is encountered, it sets its signal processors to decode with a certain processor algorithm. A stream of data composed of many speech objects encoded in a variety of algorithms works if each unique speech object contains a speech header at the beginning of the file. Playing from a voice file descriptor position to some arbitrary point within the voice file can cause garbled speech if the first four bytes do not represent a speech header and if this speech is preceded by a voice object encoded with a different algorithm. To avoid this problem, you can prepend all arbitrarily positioned voice plays with a speech header using irBPlay(3IRAPI). The following example illustrates this technique.

In this example, the array of unsigned shorts is set to contain the byte sequence 0xff, 0xaa, 0x<code_type>. The algorithm type of the voice file associated with a voice file descriptor is obtained via a call to irGetAlgorithm(3IRAPI), The byte sequence 0xff, 0xaa instructs the voice card that the subsequent byte is the algorithm in which the subsequent speech is encoded. The call to irBPlay guarantees that the voice data played from voice file descriptor vfd is prepended with a speech header of the proper type, thereby allowing the passing data to the voice card of a different algorithm than that currently being decoded by the voice card.

Note:
This technique might degrade performance on large channel count systems since, internally, an entire speech block and speech file is allocated for the buffer play (that is, each buffer play acts like a unique file play). You may want to play a speech file created at installation time that contains only the header. In this case, the file is shared across channels and is likely to be cached in the speech buffer cache.

int play_vfd_with_head(channel_id cid, vf_descriptor vfd, int count)
{
unsigned short header[2];

header[0] = 0xffaa;
header[1] = ((unsigned short) irGetAlgorithm(vfd)) & 0xff;

if ( irBPlay(cid, tag, header, 4) == IRR_FAIL ||
irPlay(cid, tag, vfd, count) == IRR_FAIL ) {
return(IRR_FAIL);
}
return(IRR_OK);
}

© 2006 Avaya Inc. All Rights Reserved.