Delen via


PromptBuilder.AppendAudio Method

Definition

Appends a specified audio file to a PromptBuilder object.

Overloads

AppendAudio(String)

Appends the specified audio file to the PromptBuilder.

AppendAudio(Uri)

Appends the audio file at the specified URI to the PromptBuilder.

AppendAudio(Uri, String)

Appends the specified audio file and alternate text to the PromptBuilder.

AppendAudio(String)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends the specified audio file to the PromptBuilder.

public:
 void AppendAudio(System::String ^ path);
public void AppendAudio (string path);
member this.AppendAudio : string -> unit
Public Sub AppendAudio (path As String)

Parameters

path
String

A fully qualified path to the audio file.

Applies to

AppendAudio(Uri)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends the audio file at the specified URI to the PromptBuilder.

public:
 void AppendAudio(Uri ^ audioFile);
public void AppendAudio (Uri audioFile);
member this.AppendAudio : Uri -> unit
Public Sub AppendAudio (audioFile As Uri)

Parameters

audioFile
Uri

URI for the audio file.

Examples

The following example initializes a new instance of the PromptBuilder class and then adds text to it, followed by an audio file.

using System.Speech.PromptBuilder;  

public void SimpleConcatenation()  
{  
    // Add a prompt fragment from a .wav file.  
    PromptBuilder builder = new PromptBuilder ();  
    builder.AppendText("How are you today?");  
    builder.AppendAudio(new Uri ("http://www.speech.microsoft.com/ding.wav"));  
}  

The following markup shows the equivalent SSML markup.

<speak xmlns="http://www.w3.org/2001/10/synthesis"  
       xmlns:ms="http://www.microsoft.com/speech/synthesis" xml:lang="en">  

  How are you today?  
  <audio src="http://www.speech.microsoft.com/ding.wav" />  

</speak>  

Applies to

AppendAudio(Uri, String)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends the specified audio file and alternate text to the PromptBuilder.

public:
 void AppendAudio(Uri ^ audioFile, System::String ^ alternateText);
public void AppendAudio (Uri audioFile, string alternateText);
member this.AppendAudio : Uri * string -> unit
Public Sub AppendAudio (audioFile As Uri, alternateText As String)

Parameters

audioFile
Uri

URI for the audio file.

alternateText
String

A string containing alternate text representing the audio.

Examples

The following examples adds an audio file to a PromptBuilder instance and specifies text to speak if the audio file cannot be played.

using System.Speech.PromptBuilder;  

public void SimpleConcatenation()  
{  

    // Concatenate a prompt fragment from a .wav file.  
    PromptBuilder builder = new PromptBuilder ();  
    builder.AppendAudio(new Uri ("C:\\OnHold.wav"), "Your call will be answered in the order it was received");  
}  

The following markup shows the equivalent SSML markup.

<speak xmlns="http://www.w3.org/2001/10/synthesis"  
       xmlns:ms="http://www.microsoft.com/speech/synthesis" xml:lang="en">  

  <audio src="C:\OnHold.wav"> Your call will be answered in the order it was received. </audio>  

</speak>  

Remarks

The speech synthesis engine will speak the alternate text if the audio file cannot be played.

Applies to