You might want to import or export a voice segment from within your application
while it is running, for example, if your application announces status updates
which change throughout the day. To do this, use the WVR.importVoiceSegment() and WVR.exportVoiceSegment() methods.
There are two versions of each method, one uses a file and the other uses
a data stream. The parameters are as follows:
- segment: the name of the VoiceSegment to
be imported or exported. If the voice segment does not exist, the method will
throw an exception.
- Either
- file: the name of the file to import or export from
Or
- in or out: a java.io.InputStream or java.io.OutputStream object, as appropriate.
- type: the type of the audio data. Possible values
are
- WVR.AUDIO_TYPE_WAVE: the audio is in wave format.
- WVR.AUDIO_TYPE_ALAW: the audio is in A-Law format.
- WVR.AUDIO_TYPE_ULAW: the audio is in U-Law format.
- null: the audio type will be automatically determined.
For example, to import a voice segment called 'status', by reading a file
called 'hour1' recorded in A-Law format, using a
WVR object called
'wvr':
wvr.importVoiceSegment(status, hour1, WVR.AUDIO_TYPE_ALAW);
To
export the 'status' voice segment to an
OutputStream called 'out',
with the audio type automatically determined:
wvr.exportVoiceSegment(status, out, null);