Wave file playback using SpeakWave and SpeakInteractiveWave variables will result in small delays between the playback of individual files.
This delay can be avoided by combining multiple wave files into a single file, and then playing back only the single wave file.
To combine multiple wave files into a single file, use the ACCTools Audio Splicing Tool. This object is created using CreateObject("ACCTools.AudioSplicer"). The object has a Splice method which accepts the name of the output file followed by the names of the 10 wave files to combine as the parameters. To combine fewer than 10 wave files, leave the additional parameters blank.
The following sample code demonstrates how to combine two wave files into a single file for playback:
' Create the audio splicer object.
Set obj = CreateObject("ACCTools.AudioSplicer")
' Combine Miami.wav and Chicago.wav and
' create Combined.wav.
obj.Splice AppPath & "\Examples\Combined.wav", _
AppPath & "\Examples\Miami.wav", _
AppPath & "\Examples\Chicago.wav", "", "", "" ,"" ,"" ,"", "", ""
' Speak the combined file.
SpeakWave1 = AppPath & "\Examples\Combined.wav"
Similarly, more wave files can be combined into a single wave file:
' Create the audio splicer object.
Set obj = CreateObject("ACCTools.AudioSplicer")
' Combine Miami.wav and Chicago.wav repeatedly and
' create Combined.wav.
obj.Splice AppPath & "\Examples\Combined.wav", _
AppPath & "\Examples\Miami.wav", _
AppPath & "\Examples\Chicago.wav", _
AppPath & "\Examples\Miami.wav", _
AppPath & "\Examples\Chicago.wav", _ AppPath & "\Examples\Miami.wav", _
AppPath & "\Examples\Chicago.wav", _ AppPath & "\Examples\Miami.wav", _
AppPath & "\Examples\Chicago.wav", _
AppPath & "\Examples\Miami.wav", _
AppPath & "\Examples\Chicago.wav"' Speak the combined file.
SpeakWave1 = AppPath & "\Examples\Combined.wav"
Experiment with the sample code by copying and pasting it into a VBScript Macro.
If necessary, you can also use the GetLength method of the audio splicing object to determine the length (in seconds) of the combined wave file. For example, to get the length of the combined file created above, add the following line at the end of the sample code shown above:
MsgBox obj.GetLength(AppPath & "\Examples\Combined.wav")