Click or drag to resize

VoiceResourcePlay Method (String)

Plays a sequence of files, provided each file plays to completion.

Namespace:  VoiceElements.Client
Assembly:  VoiceElementsClient (in VoiceElementsClient.dll) Version:
public TerminationCode Play(
	string[] filenames


Type: SystemString
An array of files to play where each element is the path and file name you would like to play. The elements will play in the sequence of the array index.

Return Value

Type: TerminationCode
A Termination Code indicating how the play ended. Typically, you will use this to determine what to do next.
Supported File Types

Voice Elements supports a wide range of audio file types and formats, for a detailed list of these formats, see Supported Audio Codecs. Most of these formats that we recommend are Wave Files. You may need to convert your audio into one of these formats, depending on the source.

Telephony Sound Processing: Audio Quality

Before discussing converting your audio files, we need to point out that all audio transmitted over a telephony carrier is typically converted down to 8khz 8bit Mulaw (aka G711) quality in transmission (some countries use ALaw, and in addition to G711, G729 is also another codec that can be used). Therefore, higher quality files will not result in a better sounding connection. We also recommend converting your files to this codec to save conversion before tranmission every time. To play files of a different type, you may change the Voice Resource Codec Property to any of the supported codecs.

Converting Your Audio Files

There are several applications available that you can easily use to convert to 8khz 8bit Mulaw format from almost any other format. We have had good results with GoldWave, WavePad and Open Source Audacity. If you need to convert your files in real time (i.e. during a call), we recommend Open Source SOX.

FAQ: Audio Doesn't Sound Clear?

This is usually a codec mismatch. Either convert your files or change the Voice Resource Codec Property to the one in which your files were encoded.

FAQ: Can I Use MP3 Files?

Voice Elements does not support MP3 files, which are usually in a far higher quality than needed for telephony. See above on ways to convert your files to 8khz 8bit Mulaw.

The following sample code sets up a Channel Resource, Dials a Call, retrieves a Voice Resource, sets the Audio Codec to the recommended and plays and array of 3 files.
public void DialOutAndPlayArray()
    // To get a channel, you must first get a link to a Telephony Server.  You may need to pass a username password here.
    TelephonyServer m_TelephonyServer = new TelephonyServer();

    // Get your channel resource from the server
    ChannelResource m_ChannelResource = m_TelephonyServer.GetChannel();

    // Example 1: Dial an oubound call
    string phoneNumber = "2135551212";

    // Get the voice resource and store in a variable for local use
    VoiceResource m_VoiceResource = m_ChannelResource.VoiceResource;

    // Set the codec to the desired audio format - This is our recommeded for all audio!
    m_VoiceResource.Codec = Codec.MULAW_8Khz_8Bit;

    // Build an array of files
    string[] fileList = new string[3];
    fileList[0] = @"C:\Audio\HelloCaller.wav";
    fileList[1] = @"C:\Audio\HowAreYou.wav";
    fileList[2] = @"C:\Audio\NiceToKnowYou.wav";

    // Play all files in the array we built above

    // Get digits from the caller
    TerminationCode terminationCode = m_VoiceResource.GetDigits();
    string m_Digits = m_VoiceResource.DigitBuffer;

    // First, play an audio file to say Thanks for the Digits

    // Take your code from here ... 
See Also