I've found a workaround for the Run() command working in parallel and the script trying to play the sound file before it is generated. At first I thought I'd simply wait for the file to exist with a "repeat until FileExists('C:\testfile.wav');" command, but that doesn't work as the file is created and the script moves on to play the sound before the sound is actually completely written to the file.
However, if I name the sound file one thing, call the sound generator to create it, and then wait until a rename of that file is successful, the wait works - I'm guessing because the rename fails while the sound generator has the file open. A bit ugly, but it works:
var CustomMessage : String = 'This is my custom message to be converted into a sound file.';
if FileExists('C:\testfile.tmp') then DeleteFile('C:\testfile.tmp');
if FileExists('C:\testfile.wav') then DeleteFile('C:\testfile.wav');
Run('C:\Program Files\Cepstral\bin\swift','"'+CustomMessage+'" -o "C:\testfile.tmp" -p audio/encoding=pcm16,audio/sampling-rate=8000');
repeat until RenameFile('C:\testfile.tmp'), 'C:\testfile.wav');
sound('C:\testfile.wav');
This works with phonesound() too to play the message to the caller if your device supports it.
Some caveats:
1) If your message string is too long, this approach will likely overflow the command line causing problems. The only way around this I can think of would be to write the message text to a file and then have the Cepstral software create the sound file from that (see Cepstral documentation for command line format to do this). Be sure to set the time alotted to maximum phonesound() message appropriately (Options > Devices > Advanced) if you're using that function.
"On computers running Microsoft Windows XP or later, the maximum length of the string that you can use at the command prompt is 8191 characters. On computers running Microsoft Windows 2000 or Windows NT 4.0, the maximum length of the string that you can use at the command prompt is 2047 characters."
http://support.microsoft.com/kb/830473
2) There is some lag while the script waits for the sound file to be generated. During this time the phone continues to ring. The lag isn't problematic on my system but your mileage may vary.
3) This was easy to implement as above for a single phone line. You'd have to manage file names better to avoid file name collisions with multiple lines.[/url]