Compartilhar via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

PromptBuilder.AppendText Method (String, PromptRate)

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

Namespace:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Sub AppendText ( _
    textToSpeak As String, _
    rate As PromptRate _
)
'Usage
Dim instance As PromptBuilder
Dim textToSpeak As String
Dim rate As PromptRate

instance.AppendText(textToSpeak, rate)
public void AppendText(
    string textToSpeak,
    PromptRate rate
)

Parameters

  • textToSpeak
    Type: System.String
    A string containing the text to be spoken.

Examples

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

using System;
using Microsoft.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.SetOutputToWaveFile(@"C:\test\Hardware.wav");

        // Create a SoundPlayer instance to play the output audio file.
        System.Media.SoundPlayer m_SoundPlayer =
          new System.Media.SoundPlayer(@"C:\test\Hardware.wav");

        // 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 prompt and play back the output file.
        synth.Speak(speakRate);
        m_SoundPlayer.Play();
      }

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

See Also

Reference

PromptBuilder Class

PromptBuilder Members

AppendText Overload

Microsoft.Speech.Synthesis Namespace