Voice coding instructions provide script facilities for adding or removing phrase numbers to or from a selected speech file. These instructions also store speech within these or previously defined phrase allocations. These facilities may be used, with suitable script prompts, to record user voice or touch-tone messages.
The feature of ending the voice coding session by pressing a touch-tone key (referred to as talkoff) can be disabled using tflush(1) before the vc instruction. This allows the user to encode the touch tones as well as the speech. See Voice Output Instructions for details about the tflush instruction.
The voice coding instructions are described below. Following these is an example of a script for voice coding and play.
phreserve(type.phrase, type.talk, type.time, type.style)
The phreserve instruction creates an area in a talkfile that is used to store a phrase. This phrase is later encoded by the vc instruction. The arguments for the phreserve instruction are:
Argument |
Description |
type.phrase |
Phrase id of the phrase to be created (valid range is 1-65,535). |
type.talk |
Talkfile id of the talkfile where the phrase is stored (valid range is 1-16,383). |
type.time |
Amount of space, or time (in seconds), to be reserved for a phrase in the talkfile. |
type.style |
Coding style and rate to be used. Valid coding styles and rates are defined in the header file codestyle.h in the directory /att/include. This file should be included in the script by an include instruction. If the style specified is not valid, the phreserve instruction fails. |
If type.phrase is -1, the system assigns a phrase id and returns this id in r.1. The phrase id can be used to reference the phrase (for example, in a talk instruction) once it has been coded and stored in the talkfile by the vc instruction. If type.talk is -1, the system selects the default value 255 for the talkfile and returns the id of the selected talkfile in r.0.
Note:
If there are two phreserve instructions, there must be a vc instruction between them or the second phreserve instruction fails.
When both type.talk and type.phrase are -1, both a phrase id and talkfile id are chosen by the system and returned in r.1 and r.0, respectively. These selections start with the largest previously unassigned phrase number of talkfile 255. Subsequent phrase selections fill unused phrases of talkfile 255 toward phrase 0. Since r.0 and r.1 can be used implicitly to store talkfile or phrase ids, the script writer must take care to save the contents of these registers before the phreserve command is executed.
If type.phrase matches the phrase id in the specified talkfile, the existing phrase is replaced by the new phrase. The values 0 and -1 for the type.time argument indicate that the phreserve instruction should not allocate any space. If enough space is available to store the phrase when coding ends, the phrase is stored. If there is not enough space, an error message is issued from the vc instruction.
If the instruction is completed successfully, the return values are talkfile id in r.0 and phrase id in r.1. If the instruction is not completed successfully, the return value in r.0 is negative.
phremove(type.phrase, type.talk)
The phremove instruction removes the phrase specified by the type.phrase argument from the talkfile specified by the type.talk argument. The valid values for type.phrase are 1-65,535. The valid values for type.talk are 1-16,383. Type.phrase must be a valid phrase id. type.talk may have the value -1. If type.talk is -1, then the talkfile id used is the current talkfile.
If the phremove instruction is successful, it returns the phrase id of the phrase removed in r.0. If the instruction is not successful, it returns a negative value in r.0.
vc (flag,type.time,type.rate [, wait_flag ])
The vc instruction codes speech into a phrase in a talkfile.
For the first argument, 'b' (for begin coding) is accepted. Another character value, 'p' (for prompt) may be used to play a short beep just before voice coding starts. Note that this beep must be included in the prompt, either as a separate phrase or as part of the phrase.
The type.time argument specifies the maximum duration, in seconds, of the coding session. A value n for type.time specifies a coding session lasting up to n seconds. A value of -1 or 0 for type.time specifies the default maximum duration of 45 seconds. Coding can be terminated at any time by entering a touch tone.
The type.rate argument specifies the coding rate in kilobytes per second (Kbps). If the value given for this argument is not a valid rate or type, the instruction fails.
The feature of ending the voice coding session by entering a touch tone (referred to as talkoff) can be disabled using tflush(1) before the vc instruction. This allows the user to encode the touch tones as well as the speech. See Voice output instructions for details on the tflush instruction.
The default value for the optional wait_flag argument is 1, which causes vc() to return when voice coding is complete. If this argument is used with a value of 0, vc() returns immediately after voice coding has started, allowing the script to execute more instructions while doing voice coding. This is useful for doing voice coding and speech recognition (with the getinput() instruction) simultaneously. Note that barge-in cannot be used during simultaneous recognition and coding. Also, recognition and coding should not occur on the same speech resource. When voice coding is started without waiting for completion, vc() returns a value of 0 in register 0 (r.0). Voice coding must be stopped at a later time by the tstop() instruction with the optional wait_flag argument set to 1 to get the return values (r.0, r.1, and r.2) from the completed voice coding.
If the vc instruction is successfully completed, it returns the phrase id in r.0. If the vc instruction is not completed successfully, it returns -1 in r.0. If the vc instruction recorded nothing because the initial silence timeout was exceeded (see vctime), it returns -2 in r.0. r.1 contains the recorded message length in seconds (this should be 0 if r.0 is negative). r.2 is set to 1 if voice coding completes normally, 2 if coding is terminated by a touch tone (talkoff), and 3 if coding is terminated due to silence detection. That is, the intermediate silence timeout is exceeded (see vctime).
vctime(type.src,type.src)
The vctime instruction allows the application developer to set silence timeouts. The first type.src argument contains the value for the initial silence timeout. The second type.src argument contains the value for the interword silence timeout. The maximum timeout is 30 seconds.
The values for the type.src arguments and the effect on the timeout are given below:
Value |
Effective Timeout Value |
X > 0 |
X becomes the timeout value |
X = 0 |
Timeout is turned off |
X < 0 |
Timeout is set to default value (5 seconds) |
This instruction does not give a return value to indicate success or failure.