Zdieľať cez


PromptBuilder.AppendText Method

Definition

Appends text to the PromptBuilder object.

Overloads

AppendText(String)

Specifies text to append to the PromptBuilder object.

AppendText(String, PromptEmphasis)

Appends text to the PromptBuilder object and specifies the degree of emphasis for the text.

AppendText(String, PromptRate)

Appends text to the PromptBuilder object and specifies the speaking rate for the text.

AppendText(String, PromptVolume)

Appends text to the PromptBuilder object and specifies the volume to speak the text.

AppendText(String)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Specifies text to append to the PromptBuilder object.

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

Parameters

textToSpeak
String

A string containing the text to be spoken.

Examples

The example that follows creates a PromptBuilder object and appends a text string using the AppendText method.

using System;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToDefaultAudioDevice();  

        // Create a PromptBuilder object and append a text string.  
        PromptBuilder speakText = new PromptBuilder();  
        speakText.AppendText("Say the name of the song you want to hear");  

        // Speak the contents of the prompt.  
        synth.Speak(speakText);  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

Remarks

To append text that is formatted as SSML markup language, use AppendSsmlMarkup.

Applies to

AppendText(String, PromptEmphasis)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends text to the PromptBuilder object and specifies the degree of emphasis for the text.

public:
 void AppendText(System::String ^ textToSpeak, System::Speech::Synthesis::PromptEmphasis emphasis);
public void AppendText (string textToSpeak, System.Speech.Synthesis.PromptEmphasis emphasis);
member this.AppendText : string * System.Speech.Synthesis.PromptEmphasis -> unit
Public Sub AppendText (textToSpeak As String, emphasis As PromptEmphasis)

Parameters

textToSpeak
String

A string containing the text to be spoken.

emphasis
PromptEmphasis

The value for the emphasis or stress to apply to the text.

Remarks

The speech synthesis engines in Windows do not support the emphasis parameter at this time. Setting values for the emphasis parameter will produce no audible change in the synthesized speech output.

Applies to

AppendText(String, PromptRate)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends text to the PromptBuilder object and specifies the speaking rate for the text.

public:
 void AppendText(System::String ^ textToSpeak, System::Speech::Synthesis::PromptRate rate);
public void AppendText (string textToSpeak, System.Speech.Synthesis.PromptRate rate);
member this.AppendText : string * System.Speech.Synthesis.PromptRate -> unit
Public Sub AppendText (textToSpeak As String, rate As PromptRate)

Parameters

textToSpeak
String

A string containing the text to be spoken.

rate
PromptRate

The value for the speaking rate to apply to the text.

Examples

The following example creates a PromptBuilder object and appends text strings. The example uses the AppendText method to specify a slow speaking rate for the string being added, which enumerates the contents of an order.

using System;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToDefaultAudioDevice();  

        // Create a PromptBuilder object and add content.  
        PromptBuilder speakRate = new PromptBuilder();  
        speakRate.AppendText("Your order for");  
        speakRate.AppendText("one kitchen sink and one faucet", PromptRate.Slow);  
        speakRate.AppendText("has been confirmed.");  

        // Speak the contents of the SSML prompt.  
        synth.Speak(speakRate);  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

Applies to

AppendText(String, PromptVolume)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends text to the PromptBuilder object and specifies the volume to speak the text.

public:
 void AppendText(System::String ^ textToSpeak, System::Speech::Synthesis::PromptVolume volume);
public void AppendText (string textToSpeak, System.Speech.Synthesis.PromptVolume volume);
member this.AppendText : string * System.Speech.Synthesis.PromptVolume -> unit
Public Sub AppendText (textToSpeak As String, volume As PromptVolume)

Parameters

textToSpeak
String

A string containing the text to be spoken.

volume
PromptVolume

The value for the speaking volume (loudness) to apply to the text.

Examples

The following example uses the AppendText method to specify volume settings that the SpeechSynthesizer should apply to speech output.

using System;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToDefaultAudioDevice();  

        // Build a prompt that applies different volume settings.  
        PromptBuilder builder = new PromptBuilder();  
        builder.AppendText("This is the default speaking volume.", PromptVolume.Default);  
        builder.AppendBreak();  
        builder.AppendText("This is the extra loud speaking volume.", PromptVolume.ExtraLoud);  
        builder.AppendBreak();  
        builder.AppendText("This is the medium speaking volume.", PromptVolume.Medium);  

        // Speak the prompt.  
        synth.Speak(builder);  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

Remarks

The Default setting for PromptVolume is full volume, which is the same as ExtraLoud. The other settings decrease the volume of speech output relative to full volume.

Applies to