Deleting voice segments dynamically

Sometimes you need to delete a voice segment from within an application, typically when a voice segment has been recorded during the application and is not required after the application has finished. It is possible to delete the segment during a call, before the call starts or after the call has finished.

If the voice segment does not exist, you will receive an exception.

To delete a voice segment, use the WVR.deleteVoiceSegment() method, which takes one parameter, the name of the VoiceSegment to be deleted.

For example, to define a voice segment named CallerMessage in the RECORDING category, record to it and then delete it:
public class InApp extends WVRApplication {
  .
  .
  .
  // Create the voice segment object for recording the message
  VoiceSegment vs_caller_message = new VoiceSegment(RECORDING, "CallerMessage");
  .
  .
  .
  // Record the message
  call.record(VS_Caller_Message, -1, false, true);
  .
  .
  .
  // During the call handling, the voice segment is no longer required and can be deleted
  wvr.deleteVoiceSegment(VS_CALLER_MSG);
  .
  .
  .
}

You can delete the voice segment at any time during the application, as long as there is a WVR object to invoke the method on.